Update this code to include multiple images?

Bret1

Board Regular
Joined
Jun 14, 2013
Messages
199
I don't know VBA, but I was able to make this simple VBA code from watching multiple Youtube videos.
Basically, it allows you to put a complete filename of a photo in cell "A2", press the "Refresh" button, and the picture will be displayed. Then the file can be saved with that picture displayed. When the worksheet is re-opened, that picture will still be displayed as it was, but if the "Refresh" button is pressed and the actual picture was changed in the directory filename, the picture on the page will refresh.
Here is the code...
Code:
Private Sub cmdDisplayPhoto_Click()
Application.ScreenUpdating = False
Dim myObj
Dim Pictur
Set myObj = ActiveSheet.DrawingObjects
For Each Pictur In myObj
If Left(Pictur.Name, 7) = "Picture" Then
Pictur.Select
Pictur.Delete
End If
Next

Dim PictureName As String
PictureName = Range("A2")

On Error GoTo errormessage:
ActiveSheet.Shapes.AddPicture Filename:=PictureName, linktofile:=msoFalse, savewithdocument:=msoTrue, Left:=190, Top:=30, Width:=300, Height:=300

errormessage:
If Err.Number = 1004 Then
MsgBox "File does not exist." & vbCrLf & "Check the filename again"
Range("A2").Value = ""

End If
Application.ScreenUpdating = True
End Sub

I want to add three things to this, but need help....
First...The ability to display (assign) a "short" name to the full filename of the photo.....
If I have several photos of islands in my island directory, I may want it to display the name "Hawaaii", but reference the full filename.
Maybe for this, have a control button. Activate a cell, click on the button and pop-up displays with "actual filename?" and "display name?" inputs.

Second... Have the top-left corner of the picture display in the cell under the "Display Name" cell.

Third... Have the ability to have several "Display Name" cells and reference pictures.

Thanks so much in advance!
 

Excel Facts

What is the shortcut key for Format Selection?
Ctrl+1 (the number one) will open the Format dialog for whatever is selected.

Forum statistics

Threads
1,215,219
Messages
6,123,688
Members
449,117
Latest member
Aaagu

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