Page 2 of 2 FirstFirst 12
Results 16 to 24 of 24
  1. #16
    Super Moderator
    Join Date
    May 2002
    Location
    Canberra, Australian Capital Territory, Australia
    Posts
    3,892
    Thanks
    0
    Thanked 188 Times in 172 Posts
    Quote Originally Posted by fhutt View Post
    I removed the } after the \p.
    This } came from your sticky post on the forum.
    That is only partly true. The field there is represented as:
    {INCLUDEPICTURE "{FILENAME \p}\\..\\Image.png"}
    That is the entire field. Your field, though, has additional switches - which can only occur before the terminating }. Since you have that, the other does not belong there.

    I also note you're using the \d switch, which the field code I posted does not. I suggest trying the field without that switch, too.

    If you still have no joy, attach the document and its image file to a post (delete anything sensitive) and I'll take a look at it. You do this via the paperclip symbol on the 'Go Advanced' tab at the bottom of this screen.
    Cheers,

    Paul Edstein
    [MS MVP - Word]

  2. #17
    New Lounger
    Join Date
    Jul 2014
    Posts
    8
    Thanks
    0
    Thanked 0 Times in 0 Posts
    You are right.
    I removed everything except your original text.
    Now it looks like:
    { INCLUDEPICTURE "{FILENAME \p}\\..\\Penguins.jpg" }
    I am tickled pink! It works.
    The \d \* MERGEFORMAT comes from Word. When I insert a picture through the menus, these switches are there. I assumed they were required.
    Sorry to have been so difficult.
    Thank you so much.
    Last edited by fhutt; 2014-07-20 at 20:37.

  3. #18
    New Lounger
    Join Date
    Jul 2014
    Posts
    8
    Thanks
    0
    Thanked 0 Times in 0 Posts
    In light of the additional editing required by inserting this field for every picture, to make it work as relative addressing, is almost too tedious.
    I think, that since the standard insertion of an image, by using the menu system for each link, is much simpler, if there was an automatic macro was inserted into the document that run at startup, would update each field, would be an easier solution.
    Just a thought.
    Frank

  4. #19
    Super Moderator
    Join Date
    May 2002
    Location
    Canberra, Australian Capital Territory, Australia
    Posts
    3,892
    Thanks
    0
    Thanked 188 Times in 172 Posts
    Quote Originally Posted by fhutt View Post
    In light of the additional editing required by inserting this field for every picture, to make it work as relative addressing, is almost too tedious.
    It would, of course, be possible to do this using Find/Replace. Simply:
    • press Alt-F9 to expose the document's field codes
    • create the FILENAME field and its trailers (i.e. {FILENAME \p}\\..\\)
    • copy the FILENAME field and its trailers to the clipboard
    • open the Find/Replace dialogue and input the part of the path to be replaced as the Find text, with ^c as the Replace expression, then click 'Replace All'.
    I think, that since the standard insertion of an image, by using the menu system for each link, is much simpler, if there was an automatic macro was inserted into the document that run at startup, would update each field, would be an easier solution.
    Anything that entails macros raises macro-security and user-response issues, aside from which one might also argue that static images should be embedded in the document rather than being linked to it.
    Cheers,

    Paul Edstein
    [MS MVP - Word]

  5. #20
    New Lounger
    Join Date
    Jul 2014
    Posts
    8
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Yes, editing can be made easier, but, needing the relative addressing is not often. In between those times needed, I am sure I would forget how to do it, so I would need to search out the method used last time.
    This is why I thought that a macro would fix this by entering it into my normal template, it would be there automatically when I create a new document, and it would just work.
    I take your comment about the security issue.
    I am so happy though, that I now have a method of applying relative addressing for links.
    Thank you very much.
    Frank

  6. #21
    New Lounger
    Join Date
    Jul 2014
    Posts
    2
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Hey everyone. First post here and google searching brought me to the forums.

    I'm using Office 2007, and have a Word file that has Links to various Excel tables all in the same/single Excel file. About 60 of them actually. The excel file is also a macro enabled. xlsm file. Both the Word and Excel file are basically a template that my staff will pull down from our network to their local PC. They will then rename both files for their current assignment. And both should typically always be in the same working folder as well. I believe macropod's macro is designed to edit the links to a relative path in that same folder?

    But when I run the macro, I get a an error that takes to me these lines

    Code:
     ' Replace the link to the external file if they differ.
       If OldPath <> NewPath Then .LinkFormat.SourceFullName = _
        Replace(.LinkFormat.SourceFullName, OldPath, NewPath)

    I'm not certain, but should the macro be prompting for the new file location?

    I think for my purposes, all I really need is a macro that would prompt the user for the new/correct folder and file location and then update all of the linked tables.

    Any help would be greatly appreciated.

    Thanks
    PT

  7. #22
    Super Moderator
    Join Date
    May 2002
    Location
    Canberra, Australian Capital Territory, Australia
    Posts
    3,892
    Thanks
    0
    Thanked 188 Times in 172 Posts
    Do the LINK fields contain the path details? For example, when the error occurs, what do you see if you choose Debug and hover over OldPath & NewPath?

    And no, the macro isn't supposed to give any prompts - it can work out for itself what the current folder is.
    Cheers,

    Paul Edstein
    [MS MVP - Word]

  8. #23
    New Lounger
    Join Date
    Jul 2014
    Posts
    2
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Hey Macrpod.

    Thanks for getting back to me and trying to help.

    I'm not sure how to copy and past that info here, but Yes when I hover over each one, I see what the current value is but not sure if they are all correct or not


    Example
    .SourceFullName shows the correct path and filename
    .OldPath shows the correct path, the file name, and the cells being linked ; ie C:\path\to\file\filename.xlsm!Cover Charts!R28C29

    and .NewPath only shows the new file path, but neither shows the file name or the cell info.

    And if I stop the macro and rerun it a 2nd time without exiting word, I get an error the excel file is already open, and .OldPath then returns just the file path, and no file name, etc.

    You probably know it, but its all on line 100 of the macro.

    FYI..... Reason I was curious about if the macro prompted for a the new/correct file name as in my case the user will likely be renaming both the Word and Excel docs at the start of every project. Is the macro looking to replace the path for a file with the same file name?


    And thanks again for the help !
    Last edited by ptmuldoon; 2014-07-29 at 13:38.

  9. #24
    Super Moderator
    Join Date
    May 2002
    Location
    Canberra, Australian Capital Territory, Australia
    Posts
    3,892
    Thanks
    0
    Thanked 188 Times in 172 Posts
    The content of .OldPath (i.e. C:\path\to\file\filename.xlsm!Cover Charts!R28C29) shows you have a mal-formed LINK field. The path includes neither the filename nor the link address. All you should see there is 'C:\path\to\file'.
    Cheers,

    Paul Edstein
    [MS MVP - Word]

Page 2 of 2 FirstFirst 12

Posting Permissions

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