PDA

View Full Version : Embed object's SourceFullName?



AK3003
11-24-2008, 12:16 AM
Friends,

I have an automated program, which embeds .jpeg file as an attachment, displays as an icon in my Word document (v2007). Was able to get the icon label (which matches the file name say Test.jpeg) whereas I could not get the file path details, which got saved in my machine.

For each inShape in ActiveDocument.InlineShapes.Count
Set objOLE = inShape.OLEFormat
fileName = objOLE.IconLabel
'returns displayed icon name (matches file name)

Set objLink = inShape.LinkFormat
srcFile = objLink.SourceFullName
' returns Nothing
Next

and have read somewhere that LinkFormat object is not applicable for embedded objects.

Is it possible to get the source full name (file name includes file path) associated to a embed object?

Thanks in Advance.
--AK.

fumei
11-24-2008, 02:30 PM
1. "which embeds .jpeg file as an attachment"

If it is embedded it is NOT an attachment.

2. For each inShape in ActiveDocument.InlineShapes.Count

should get you a Compile error.

"For Each may only iterate over a collection object or an array"

Your code line does neither.

3. "LinkFormat object is not applicable for embedded objects."

Correct. It is either linked OR embedded.

I am quite confused as to what is precisely going on. You say you are getting a return from:
FileName = objOLE.IconLabel

How?

I also do not understand the multitude of variables you are using. Why do you have something like:
Set objLink = inShape.LinkFormat
srcFile = objLink.SourceFullName
when


srcFile = inShape.LinkFormat.SourceFullName

is exactly the same thing - if you are properly declaring variables. I must admit I have my doubts.

LinkFormat means...."Link"

It will work for object that are, well, linked. You can check the Type of the InlineShape. If the .Type is not:

wdInlineShapeLinkedOLEObject
wdInlineShapeLinkedPicture
wdInlineShapeLinkedPictureHorizontalLine

then LinkFormat is invalid.

N.B. there may be other new Types in 2007. I don't know.

macropod
11-24-2008, 05:18 PM
Hi AK,

Since you already have code to insert the object and name it, that is the code you need to modify to capture the file path - at the same time. Once an object is embedded (as distinct from being linked) into a Word document, it is generally no longer possible to retrieve the original file path.

Cheers

AK3003
11-24-2008, 10:16 PM
Hi fumei & macropod,

Thanks a ton for your valuable suggestions.

Thanks in Advance.
--AK.