Page 2 of 2 FirstFirst 12
Results 16 to 30 of 30
  1. #16
    Super Moderator
    Join Date
    May 2002
    Location
    Canberra, Australian Capital Territory, Australia
    Posts
    3,978
    Thanks
    0
    Thanked 208 Times in 189 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 21: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,978
    Thanks
    0
    Thanked 208 Times in 189 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,978
    Thanks
    0
    Thanked 208 Times in 189 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 14:38.

  9. #24
    Super Moderator
    Join Date
    May 2002
    Location
    Canberra, Australian Capital Territory, Australia
    Posts
    3,978
    Thanks
    0
    Thanked 208 Times in 189 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]

  10. #25
    New Lounger
    Join Date
    Nov 2014
    Posts
    2
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Excel file is already open

    Hi all,

    when I execute macropod's macro (Rev. 2014-09-24 at 00:27) to update {LINK } fields to an Excel 2007 file in a Microsoft Word 2007 document, I get the following error message:

    Window title: Microsoft Office Excel
    Message: A document with the name 'DATA.XLSX' is already open. You cannot open two documents with the same name, even if the documents are in different folders. To open the second document, either close the document that is already open, or rename one of the documents.

    In detail:

    I have two files:
    - FOLDER1\DOCUMENT.DOCM and
    - FOLDER1\DATA.XSLX.

    FOLDER1\DOCUMENT.DOCM contains several link fields to specific cells in FOLDER1\DATA.XSLX and the macro to update the folder names.

    The macro works fine when I rename FOLDER1 or move it to a different location!
    The error message only appears when I make a copy of FOLDER1, e.g. FOLDER2 and then open FOLDER2\DOCUMENT.DOCM.

    The following seems to happen:
    When FOLDER2\DOCUMENT.DOCM is opened Word calls Excel which opens/locks FOLDER1\DATA.XSLX in the background (because the absolute paths have not yet changed), although I cannot see an Excel process in the task manager.
    When macropod's macro is then executed, the above-mentioned Excel error message appears. The debugger marks the following line:

    Code:
    .SourceFullName = Replace(.SourceFullName, OldPath, NewPath)
    So I guess when .SourceFullName is changed by the macro, Word calls Excel again which tries to open the file FOLDER2/DATA.XSLX now (maybe to check if the file exists or to update the field content) in the background (an Excel process is now present in the task manager) but fails, because FOLDER1\DATA.XSLX is already open or locked by Excel and has the same file name.

    If I rename FOLDER1 to FOLDER3 before opening FOLDER2\DOCUMENT.DOCM, Word cannot find FOLDER1\DATA.XLSX and the macro works fine.

    Does anybody have an idea how to prevent that opening FOLDER2\DOCUMENT.DOCM and/or changing the variable .SourceFullName lets Excel open/lock the DATA.XSLX file(s)?

    Thank you!
    Jens

  11. #26
    Super Moderator
    Join Date
    May 2002
    Location
    Canberra, Australian Capital Territory, Australia
    Posts
    3,978
    Thanks
    0
    Thanked 208 Times in 189 Posts
    Try changing the document's link updating to manual (via the Edit Links dialog) and/or unchecking Word's 'update automatic links at open' option.
    Cheers,

    Paul Edstein
    [MS MVP - Word]

  12. #27
    New Lounger
    Join Date
    Nov 2014
    Posts
    2
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Thank you for your quick response.

    Unfortunately, changing all links to manual and unchecking the 'update automatic links at open' option doesn't solve the issue.

    Jens

  13. #28
    New Lounger
    Join Date
    Dec 2014
    Posts
    1
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Macropod,

    I've read your threads, and I'm still utterly lost. Can you take me step by step from the beginning? I have no background in macros what so ever and am using Microsoft Word 2010.

    I've been handed a project to make 11 flashdrive copies of a master document and it's links. I've linked all the documents to the master document, but when another computer uses the flashdrive, if it isn't in their F:// drive, the links don't work. I've tried editing hyperlinks and hyperbase, and what not but no luck.

    All I want is for the supporting documents in the "Linked Documents" folder to appear when a link is clicked on in the master document.

    The drive looks like this:

    F://

    Folder: EasternWVCTC

    Subfolder: Linked Documents
    Live Word - Master File
    PDF - Master File

    All of the hyperlinks are within the Subfolder: Linked Documents...

    Thank you so much for your help...
    Last edited by jmm; 2014-12-10 at 17:02.

  14. #29
    Super Moderator
    Join Date
    May 2002
    Location
    Canberra, Australian Capital Territory, Australia
    Posts
    3,978
    Thanks
    0
    Thanked 208 Times in 189 Posts
    I don't know why you're messing around with what you describe as 'editing hyperbase', by which I assume you mean the hyperlink base. The thread (http://windowssecrets.com/forums/sho...External-Files) already has detailed instructions on what you need to do - everything except for the macro discussion late in the thread applies - simply read 'HYPERLINK' wherever the instructions refer to 'INCLUDEPICTURE'.
    Cheers,

    Paul Edstein
    [MS MVP - Word]

  15. #30
    Super Moderator
    Join Date
    May 2002
    Location
    Canberra, Australian Capital Territory, Australia
    Posts
    3,978
    Thanks
    0
    Thanked 208 Times in 189 Posts
    Quote Originally Posted by jenskl View Post
    Unfortunately, changing all links to manual and unchecking the 'update automatic links at open' option doesn't solve the issue.
    The only thing I can think of that would account for that is a LINK field in a page header/footer. Do you have any of those?
    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
  •