Adding image to cell note, but converting to jpg first.

StedDOOM

New Member
Joined
Jul 15, 2022
Messages
12
Office Version
  1. 365
Platform
  1. Windows
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:

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!
 

Excel Facts

Excel motto
Not everything I do at work revolves around Excel. Only the fun parts.

Forum statistics

Threads
1,223,099
Messages
6,170,107
Members
452,302
Latest member
TaMere

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top