Results 1 to 6 of 6
  1. #1
    New Lounger
    Join Date
    Aug 2015
    Posts
    4
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Relative LINK field to document itself

    Hi,


    I use the LINK field to repeat the content of a text input form field in the same Word document and to copy cell values of an embedded Excel sheet to another embedded Excel sheet. So what I need is basically the path of all LINK fields to direct to the Word file itself. Unfortunately, the macro posted by macropod here didn't do anything for me. Did I something wrong or is this macro not suited to my purpose?

    If not, how could I solve my issue? Is it even a good idea to use the LINK field in my case?

    Thanks for help!

  2. #2
    Super Moderator
    Join Date
    May 2002
    Location
    Canberra, Australian Capital Territory, Australia
    Posts
    5,054
    Thanks
    2
    Thanked 417 Times in 346 Posts
    To update the paths of LINK fields pointing to content in embedded objects, you'll need to work through the Edit Links dialogue; the macro wasn't written to cater for those.
    Cheers,

    Paul Edstein
    [MS MVP - Word]

  3. #3
    New Lounger
    Join Date
    Aug 2015
    Posts
    4
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Quote Originally Posted by macropod View Post
    To update the paths of LINK fields pointing to content in embedded objects, you'll need to work through the Edit Links dialogue; the macro wasn't written to cater for those.
    OK, as I run further tests, it is obvious that your macro doesn't work for my purpose. Essentially, what I want is that all LINK field relate to the current file name, i.e. if I save my file with a new file (or just copy it) all links shouldn't relate to the original file but the new, current file. Similar problem was described here.

    Do you (or anybody) know a solution to this problem? Any tips how I could edit your macro (if it's even allowed?) to fulfill my needs (keep all LINKS in actual document and embedded objects linked to current filename)? Thanks!

  4. #4
    Super Moderator
    Join Date
    May 2002
    Location
    Canberra, Australian Capital Territory, Australia
    Posts
    5,054
    Thanks
    2
    Thanked 417 Times in 346 Posts
    Links to objects embedded in documents are, to say the best, problematic - they break when you change the document name, move it to a different folder or drive, etc., etc. This means, of course, that if you create a new document with links to objects embedded in it, the links will break as soon as you save the document. Since the macro is coded on the premise that regardless of all other changes, the source filename remains the same, the macro won't be able to process them correctly. To use the macro with intra-document links to embedded objects, the code would therefore have to be modified to update not only the path but also the filename.
    Cheers,

    Paul Edstein
    [MS MVP - Word]

  5. #5
    New Lounger
    Join Date
    Aug 2015
    Posts
    4
    Thanks
    0
    Thanked 0 Times in 0 Posts
    I see... Seems to be a difficult task.

    My idea was to use VBA in the embedded Excel sheet to retrieve the current path and filename. This works, but when I save and close the Word file, after reopening it the VBA code in the embedded Excel sheet is gone... So update with a new filename obviously doesn't work, still the same path... Additonally, I am not sure if it's sufficient to use the sub auto_open()


    Sub AutoOpen()
    Range("G1").Value = ThisWorkbook.Name
    End Sub
    UPDATE:

    To use AutoOpen in embedded Excel files was obvious nonsense. I managed to retrieve the path and filename directly using Word VBA code and write it in an embedded Excel cell.

    Now I have: D:\Folder\Folder\Filename.docm in the Excel cell.
    For using it as LINK path, the format of the path should be "Tabelle von D Folder Folder Filename.docm" (sorry for German, I don't know this in English).

    If I have the path in the right format, I still need to convert the text content to a formula. How to do this?
    Last edited by Tester007; 2015-08-11 at 09:49.

  6. #6
    New Lounger
    Join Date
    Aug 2015
    Posts
    4
    Thanks
    0
    Thanked 0 Times in 0 Posts
    I have stopped my efforts in this direction.

    It's much simpler to have a Word VBA function which copies cell values between two embedded Excel sheets than to set up a proper, relative link. Of course auto-refresh isn't possible, but in my case this is sufficient.

    If somebody has the same requirements as I had, here is a link to a pattern document, posted by Gerhard H.

Posting Permissions

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