Howdy y'all,
I'm currently working on a sheet where the user has requested a macro that will attach the image of an invoice to the note of a cell so they can hover over the cell to see the image of the invoice.
I've got VBA code to make it all work (sorta) but the issue is that they will almost exclusively be using .pdf, as they are scans of physical invoices. However, .png and .jpg works fine, but .pdf give me an error saying "Out of memory".
The user is not particularly tech savvy, so I'm trying to see if there's a way to work into the existing macro a function that will allow him to select the .pdf, auto convert to .jpg, then attach THAT file to the note of the cell.
Here's what I've got so far:
Thanks for any help y'all are able to give!
I'm currently working on a sheet where the user has requested a macro that will attach the image of an invoice to the note of a cell so they can hover over the cell to see the image of the invoice.
I've got VBA code to make it all work (sorta) but the issue is that they will almost exclusively be using .pdf, as they are scans of physical invoices. However, .png and .jpg works fine, but .pdf give me an error saying "Out of memory".
The user is not particularly tech savvy, so I'm trying to see if there's a way to work into the existing macro a function that will allow him to select the .pdf, auto convert to .jpg, then attach THAT file to the note of the cell.
Here's what I've got so far:
VBA Code:
Sub AttachInvoiceImage()
Dim PicturePath As String
Dim CommentBox As Comment
With Application.FileDialog(msoFileDialogFilePicker)
.AllowMultiSelect = True
.Title = "Select Comment Image"
.Filters.Clear
.Filters.Add "Images", "*.png; *.jpg; *.pdf"
.Show
On Error GoTo UserCancelled
PicturePath = .SelectedItems(1)
On Error GoTo 0
End With
Application.ActiveCell.ClearComments
Set CommentBox = Application.ActiveCell.AddComment
CommentBox.Text Text:=""
CommentBox.Shape.Fill.UserPicture (PicturePath)
CommentBox.Shape.ScaleHeight 6, msoFalse, msoScaleFromTopLeft
CommentBox.Shape.ScaleWidth 4.8, msoFalse, msoScaleFromTopLeft
CommentBox.Visible = False
Exit Sub
UserCancelled:
End Sub
Thanks for any help y'all are able to give!