Image File Path for Linked Pictures

L

Lazzaroni

I am trying to return the full source path of image files for linked images
in an Excel spreadsheet (msoLinkedPicture).

The following code does not work, but it demonstrates what I am trying to do.

Dim oShape As Shape
For Each oShape In ActiveSheet.Shapes
If oShape.Type = msoLinkedPicture Then
Debug.Print oShape.LinkFormat.SourceFullName
End If
Next

Does anyone happen to know how to return a linked picture's source name?
 
J

Joel

I got the name a little different than you were trying. I added awatch to
oshape and then open it up and started searching for the path.

Sub xyz()

Dim oShape As Shape
For Each oShape In ActiveSheet.Shapes
'If oShape.Type = msoLinkedPicture Then
abc = oShape.OLEFormat.Object.SourceName
Debug.Print oShape.OLEFormat.Object.SourceName
'End If
Next
End Sub
 
L

Lazzaroni

Nick:

Good question. I wonder if my problems have something to do with the way I
am creating the image object. I use the following code:

Dim oPicture As Object
Dim sFilename As String
Set oPicture = ActiveSheet.Shapes.AddPicture(sFilename, msoTrue, msoFalse,
10, 10, 100, 100)

The images work fine and are definitely linked. If I delete the external
file, the image breaks when I restart Excel. ActiveSheet.Shapes("Picture
1").Type returns msoLinkedPicture.

I tried finding an object to return the path of the linked image file, but
the best I could do was:

ActiveSheet.Shapes("Picture 1").LinkFormat.SourceName

But that just returns the following error:

"Object doesn't support this property or method."

Joel's suggestion didn't work for me either.

Thank you for your help.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top