Consulting

Results 1 to 4 of 4

Thread: Embed object's SourceFullName?

  1. #1

    Embed object's SourceFullName?

    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.

  2. #2
    VBAX Wizard
    Joined
    May 2004
    Posts
    6,713
    Location
    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:[vba]
    FileName = objOLE.IconLabel

    [/vba]How?

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

    srcFile = inShape.LinkFormat.SourceFullName

    [/vba]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.

  3. #3
    Knowledge Base Approver VBAX Guru macropod's Avatar
    Joined
    Jul 2008
    Posts
    4,435
    Location
    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
    Cheers
    Paul Edstein
    [Fmr MS MVP - Word]

  4. #4
    Hi fumei & macropod,

    Thanks a ton for your valuable suggestions.

    Thanks in Advance.
    --AK.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •