Page 1 of 2 12 LastLast
Results 1 to 15 of 24
  1. #1
    New Lounger
    Join Date
    May 2014
    Posts
    3
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Word Relative Field Paths Discussion (2)

    Hi Macropod,

    I apologize if this is not the proper way or place to ask my question - the previous thread about the above mentioned topic was to old to reply to.

    I have read through the entire previous thread and could not solve my problem on my own.

    I have developed a Word report template for my firm witch uses links with excel. Therefor the folder containing the word to excel links must be relative allowing to folder to be moved.

    I developed the template and everything was working - the links were relative on their own without the Macro. It was not until I saw that the very last LINK field in the Word doc was broken that I came across the threads and discussions that Link fields in Word are fixed.

    I have attached 2 files (The one has the latest version of your Macro enabled, the other does not) to this thread.

    The only reason I tried your Macro is because the very last link field in my Word doc was fixed and therefor the link broke when the folder was moved. If I understand the previous discussions correctly non of the link fields should be relative?

    Thus my questions / problem is as follows:

    a) Why are the links to excel in the Word doc (the one without a Macro to update the paths) relative and why is it only the last link field that stays fixed? If I add any new Link fields they are also fixed.

    b) After I could not get the last link field to be relative I tried your Macro (please see second attached file). But again all the paths except for the very last link field are updated with the correct path. And I get the following error when opening the Word doc: "Run time error 6083: Objects in this document contain links to files that cannot be found. The linked information will not be updated."

    Your help on this will really be appreciated.

    Regards,
    Attached Files Attached Files
    Last edited by Tank26; 2014-07-14 at 08:22.

  2. Get our unique weekly Newsletter with tips and techniques, how to's and critical updates on Windows 7, Windows 8, Windows XP, Firefox, Internet Explorer, Google, etc. Join our 480,000 subscribers!

    Excel 2013: The Missing Manual

    + Get this BONUS — free!

    Get the most of Excel! Learn about new features, basics of creating a new spreadsheet and using the infamous Ribbon in the first chapter of Excel 2013: The Missing Manual - Subscribe and download Chapter 1 for free!

  3. #2
    Super Moderator
    Join Date
    May 2002
    Location
    Canberra, Australian Capital Territory, Australia
    Posts
    3,919
    Thanks
    0
    Thanked 194 Times in 177 Posts
    In Word, all link paths to external files, regardless of the link type, are absolute. For all except the LINK field (typically used to link to Excel workbooks), the other linkage fields can be made to perform relative linking by the addition of the FILENAME field, as described here: http://windowssecrets.com/forums/sho...External-Files. Relative linking with LINK, fields, however, requires a macro.

    I am unable to open either of your attachments: I get a 'does not appear to be a valid archive' message when trying to do so.
    Cheers,

    Paul Edstein
    [MS MVP - Word]

  4. #3
    New Lounger
    Join Date
    May 2014
    Posts
    3
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Hi Again,

    Thank you for the quick response,.

    I apologize for wasting you time, I recompressed the folders and tested them on another computer. This time they will open.

    I have attached the new files to this reply.

    Thank you again, you will save me allot of time if you can help me with this.

    Regards,
    Attached Files Attached Files

  5. #4
    Super Moderator
    Join Date
    May 2002
    Location
    Canberra, Australian Capital Territory, Australia
    Posts
    3,919
    Thanks
    0
    Thanked 194 Times in 177 Posts
    The macro works fine with your document for me. Do note that, since you have two source workbooks, both must be placed in the same folder as the Word document; otherwise the update process will fail and the macro will generate the message:
    "Run time error 6083: Objects in this document contain links to files that cannot be found. The linked information will not be updated."

    Quite apart from that, I seriously question why you're using so many links. IMHO you'd do far better to use DATABASE fields for much of the data. Properly coded, they can automatically omit all your '**** DELETE THIS LINE ****' lines too. For an implementation, see: http://www.msofficeforums.com/mail-m...html#post67110
    Cheers,

    Paul Edstein
    [MS MVP - Word]

  6. #5
    New Lounger
    Join Date
    May 2014
    Posts
    3
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Hi there,

    Than you again for the quick response.

    I agree with you, a database approach will better and faster. I just first need to learn myself how to do it and then make the required amendments as suggested.

    But for the moment I will still have to use the template as is.

    I still receive the same error with your macro. I tested it on three other PC's and it still did the same thing. It looks to me that whenever the word document links to a single cell in excel the macro works but as soon as it reaches a field where the word doc links with a table or chart it changes the field format which leads to the error.

    Here is the code after the macro did its job with a chart link:

    { LINK Excel.SheetMacroEnabled.12 "C:\\Users\\lbadenhorst\\Desktop\\Toetse\\Temp late V2.20\\Nuwe Template V1.35 (Safe)- edited LB.xlsm!Grafieke![Nuwe Template V1.35 (Safe)- edited LB.xlsm]Grafieke Chart 5" "" \a \p }

    It should look like this:

    { LINK Excel.SheetMacroEnabled.12 "C:\\Users\\lbadenhorst\\Desktop\\Toetse\\Temp late V2.20\\Nuwe Template V1.35 (Safe)- edited LB.xlsm" "Grafieke![Nuwe Template V1.35 (Safe)- edited LB.xlsm]Grafieke Chart 5" \a \p }

    Are you sure all the fields updated at your side?

    And like I said before, even without the macro as soon as I update the links when the word doc opens almost all the paths update. Do you know how this is possible?

    Thank you for all the help thus far. Obviously I am doing something wrong at my side I just need to find out what that is.

    Regard

  7. #6
    Super Moderator
    Join Date
    May 2002
    Location
    Canberra, Australian Capital Territory, Australia
    Posts
    3,919
    Thanks
    0
    Thanked 194 Times in 177 Posts
    As I already said, the macro worked fine for me with your document and worksheets when all are in the same folder. And yes, the fields updated. Obviously, if the LINK paths are to a folder (any folder) that already contains the workbooks, Word will update the links to those workbooks - without the need for a macro.
    Cheers,

    Paul Edstein
    [MS MVP - Word]

  8. #7
    New Lounger
    Join Date
    Jul 2014
    Posts
    8
    Thanks
    0
    Thanked 0 Times in 0 Posts
    I downloaded your Template with the macro and got the same error as above (cannot find file).
    I have a problem of my own. I get a runtime error (5) "Invalid procedure call or argument" in the GetPath function
    "StrPath = Left(StrPath, Len(StrPath) - 1)"
    I am just linking to pictures in the same folder as the word document. I am running Word 2007.
    What am I missing here?
    Thanks
    Frank
    Last edited by fhutt; 2014-07-19 at 22:08. Reason: Corrected spelling.

  9. #8
    Super Moderator
    Join Date
    May 2002
    Location
    Canberra, Australian Capital Territory, Australia
    Posts
    3,919
    Thanks
    0
    Thanked 194 Times in 177 Posts
    Hi Frank,

    Aside from not needing the macro when working with pictures (which use an INCLUDEPICTURE field), the macro error indicates that the picture concerned is not, in fact, in the same folder as the document.
    Cheers,

    Paul Edstein
    [MS MVP - Word]

  10. #9
    New Lounger
    Join Date
    Jul 2014
    Posts
    8
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Thank you for replying so quick Paul.
    It would be great if I didn't need the macro. My images are in the same folder as the document.
    If I insert "{FILENAME \p}\\..\\Image.png"} for file location and then move the document with the image.png, without the macro, the document launches with a place holder for the image. To retrieve the image, I need to Edit Links and there update.
    This is not a problem for a document with one link, but with a document with 10 links, it's a nuisance.
    Am I still doing something wrong?
    Frank

  11. #10
    Super Moderator
    Join Date
    May 2002
    Location
    Canberra, Australian Capital Territory, Australia
    Posts
    3,919
    Thanks
    0
    Thanked 194 Times in 177 Posts
    All you should need to do is check Word's options to:
    • Update fields before printing
    • Update linked data before printing
    • Update automatic links at open
    Indeed, you probably only need the last of these.
    Cheers,

    Paul Edstein
    [MS MVP - Word]

  12. #11
    New Lounger
    Join Date
    Jul 2014
    Posts
    8
    Thanks
    0
    Thanked 0 Times in 0 Posts
    I found those settings.
    The "• Update automatic links at open" was already set.
    The other 2 were not, but now set them.
    There is no change to the behaviour. After being moved to another folder and document launched, a frame for the image is shown. When an update is performed via Edit Links the image shows.
    This behaviour is the same if I have just image.png entered after the INCLUDEPICTURE or "{FILENAME \p}\\..\\Image.png"}.
    There must be something else at play here.
    Frank

  13. #12
    Super Moderator
    Join Date
    May 2002
    Location
    Canberra, Australian Capital Territory, Australia
    Posts
    3,919
    Thanks
    0
    Thanked 194 Times in 177 Posts
    What is your full INCLUDEPICTURE field code?
    Cheers,

    Paul Edstein
    [MS MVP - Word]

  14. #13
    New Lounger
    Join Date
    Jul 2014
    Posts
    8
    Thanks
    0
    Thanked 0 Times in 0 Posts
    It is either:
    { INCLUDEPICTURE "{FILENAME \p}\\..\\Penguins.jpg"} \d \* MERGEFORMAT }
    or:
    { INCLUDEPICTURE Penguins.jpg \d \* MERGEFORMAT }
    with the same behaviour.
    Frank

  15. #14
    Super Moderator
    Join Date
    May 2002
    Location
    Canberra, Australian Capital Territory, Australia
    Posts
    3,919
    Thanks
    0
    Thanked 194 Times in 177 Posts
    Your first field contains an excess '}' brace before the \d.
    Your second field lacks the path, so Word will quite possibly resort to the last (e.g. original) path stored in the document metadata.
    Both fields contain an unnecessary \* MERGEFORMAT switch, which may compromise their behaviour.

    It take it the field braces for {FILENAME \p} are created via Ctrl-F9 and are not simply typed/pasted.
    Cheers,

    Paul Edstein
    [MS MVP - Word]

  16. #15
    New Lounger
    Join Date
    Jul 2014
    Posts
    8
    Thanks
    0
    Thanked 0 Times in 0 Posts
    I have removed the \* MERGEFORMAT from the line.
    I removed the } after the \p.
    This } came from your sticky post on the forum.
    Still behaves the same.
    Frank

Page 1 of 2 12 LastLast

Posting Permissions

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