In a Word 2003 document, I have a shape that I have already inserted a picture into using the Fill Effects option and then selecting an external picture. Let's say I have created a circle shape and inserted an image called 'Grey background.gif'.
I need the Word VBA code that will tell me the name of the picture inserted into the shape because my macro will change it if it says 'Grey background.gif' but will not change it if it says something else. I can't store the name of the picture anywhere such as in a document property etc because the user may change it manually and I won't know what they have inserted.
Thanks for your help.
Microsoft ApplicationsMicrosoft Word
Last Comment
hj_daisy
8/22/2022 - Mon
GrahamSkan
Inserted shapes only have the file name if they are linked. Otherwise they have a sequential default name assigned.
Sub ShapeNames() Dim sh As Shape Dim strMsg As String For Each sh In ActiveDocument.Shapes strMsg = "Name: " & sh.Name & ". File: " If sh.LinkFormat Is Nothing Then strMsg = strMsg & " (Not Linked)" Else strMsg = strMsg & sh.LinkFormat.SourceFullName End If MsgBox strMsg Next shEnd Sub
How can I link the file so that your macro will get the filename?
It's strange that it would show the filename in the dialog box where you select the image to be inserted into the shape yet it doesn't know how to get that information.
I have attached a document showing the screen that I'm referring to.
Open in new window