Page 1 of 3 123 LastLast
Results 1 to 15 of 40
  1. #1
    Uranium Lounger
    Join Date
    Dec 2000
    Location
    Los Angeles Area, California, USA
    Posts
    7,453
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Includetext Field & Relative Paths (Word 2000/SR-3)

    I've just discovered something about the INCLUDETEXT field & why relative paths sometimes work & sometimes give an error message such as "!Syntax Error" or "Error! Cannot open file." A relative path will work (at least in Word 2000) only if the File/Open... dialog box is set to the same folder.

    I posted a method of using continuous page numbering between separate files in <post#=27832>post 27832</post#>. In that post, I mentioned that using a complete path & double backslashes, such as:

    {INCLUDETEXT "C:My DocumentsFolderSubFolderChapter 1.doc" bmk1 !}

    would always give a correct result. I also mentioned that if the source & target document were in the same folder, that you could use:

    {INCLUDETEXT "Chapter 1.doc" bmk1 !}

    Several people have said that using a relative path like that would give an error message. Now I know why. If you change the File/Open... to My DocumentsFolderSubfolder (in the example above), you will not get that error message.

    I wonder if someone who has access to other versions of Word could verify my observations.

  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
    Plutonium Lounger
    Join Date
    Nov 2001
    Posts
    10,550
    Thanks
    0
    Thanked 7 Times in 7 Posts

    Re: Includetext Field & Relative Paths (Word 2000/SR-3)

    Tested under Word 2002 on Windows XP Pro and gives similar behaviour

    Created X.doc in StuartTemp
    { Includetext } another file in StuartTemp
    Close word
    Edit included file
    Double clicked X.doc
    Checked that File > Open not pointing to StuartTemp
    Right click the included text and update works fine
    Open another file in another folder from the File Open menu
    Right click the included text in X.doc and update now gives "Error not a valid filename"

    StuartR

  4. #3
    Uranium Lounger
    Join Date
    Dec 2000
    Location
    Los Angeles Area, California, USA
    Posts
    7,453
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Includetext Field & Relative Paths (Word 2000/SR-3)

    Thanks, Stuart. This sure seems like poor design, as it means that if you open a file from either Windows Explorer or the Word MRU list, you can get an error message. Makes it difficult to distribute target & source documents that have INCLUDETEXT fields.

    Seems to me that one way around this is to have an AutoOpen macro that changes the current folder. Of course, if you have open other documents from a different folder, you can still get this problem. Any ideas of how to get around this?

  5. #4
    Plutonium Lounger
    Join Date
    Nov 2001
    Posts
    10,550
    Thanks
    0
    Thanked 7 Times in 7 Posts

    Re: Includetext Field & Relative Paths (Word 2000/SR-3)

    When I opened a file from Windows Explorer, the INCLUDETEXT field updated correctly. It only gave a problem if I opened a file from another folder and then tried to update the INCLUDETEXT field.

    A better alternative to an AutoOpen macro would be an UpdateFields macro that changes the current folder (see <post#=249730>post 249730</post#>)

    StuartR

  6. #5
    Uranium Lounger
    Join Date
    Dec 2000
    Location
    Los Angeles Area, California, USA
    Posts
    7,453
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Includetext Field & Relative Paths (Word 2000/SR-3)

    Hi Stuart:
    When I move both files, target & source, to a new folder (which is not the folder specified under Tools/Options/File Locations/Documents) & then open them from Windows Explorer, I get an error as soon as I try to update the fields. Is that the behavior you see...or did I misunderstand? You said that the field updated correctly when you opened it from Windows Explorer. I'm not sure, but I think the field doesn't update when you open it...just displays what it last showed when you closed it. Is this not true?

    The UpdateFields macro in <post#=249730>post 249730</post#> doesn't change the current folder. Right now, I'm using an UpdateFields macro that Bryan Carbonnell wrote that updates all fields in all stories.

  7. #6
    Gold Lounger
    Join Date
    Dec 2000
    Location
    New Hampshire, USA
    Posts
    3,386
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Includetext Field & Relative Paths (Word 2000/SR-3)

    Relative path works only:

    1. If the current directory happens to be the same as the one used when the relative path was gdefined.
    2. The current directory happens to have appropriate files in approppriate directories relative to that current directory.

  8. #7
    Gold Lounger
    Join Date
    Dec 2000
    Location
    New Hampshire, USA
    Posts
    3,386
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Includetext Field & Relative Paths (Word 2000/SR-3)

    Use of relative paths is NOT transportable unless an app is designed to make use of such paths.

    For example, many web sites are designed using relative paths for links.
    In my case, I do that so I can maintain the same directory tree structure on my PC, edit the HTML source, and plunk the files back on the Ubix system hosting the URL, with no change in the link code.

    If I were to (in)advertently change tghe directory structure on eithr the unix system or my PC, whithout changing the structure on the other, then the links would break.

    This is by design and the way it must be.

  9. #8
    Plutonium Lounger
    Join Date
    Nov 2001
    Posts
    10,550
    Thanks
    0
    Thanked 7 Times in 7 Posts

    Re: Includetext Field & Relative Paths (Word 2000/SR-3)

    Mine (Office XP on Windows XP) is slightly different to yours

    If I have the two files in the same folder then I can move them to a new folder, double click to open, and update fields successfully.
    If I then choose File > Open > Cancel and try to update fields again I get the error.

    The reference to [post# 249730] was simply meant to point out that an UpdateFields macro could be used to intercept F9, I knew the code to fix this wasn't there, but I didn't think it would be hard to add.

    StuartR

  10. #9
    Uranium Lounger
    Join Date
    Dec 2000
    Location
    Los Angeles Area, California, USA
    Posts
    7,453
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Includetext Field & Relative Paths (Word 2000/SR-3)

    Hi Howard:
    Thanks for responding. The problem I see is that if I were to create, say, a manual where File 1 contained Includetext & Includepicture fields referencing Files 2 & 3, all in the same folder. Suppose your folder structure is different than mine. If I use the full filepaths & send them to you, they won't work. If I use relative paths & you place them all in the same folder, they still won't work...or so it seems, unless you switch to that folder under File/Open. Do you have a way around this?

  11. #10
    Gold Lounger
    Join Date
    Dec 2000
    Location
    New Hampshire, USA
    Posts
    3,386
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Includetext Field & Relative Paths (Word 2000/SR-3)

    For example:

    1. You have a file Stuff.doc that has a relative reference to a file MoreStuff.doc in the same directory.
    2. You move BOTH files to a different directory.
    3. You then use Word to Open Stuff.doc.
    4. Update the fields in Stuff.doc.
    5. The relative reference should still be valid.
    6. Whilst in the same Word session, you decide to Open a file, say, Furry.doc in a different directory.
    7. Whilst still in the same Word session, you switch back to the Stuff.doc window.
    8. Again, update the fields in Stuff.doc.
    9. Now, the relative reference will be invalid because opening Furry.doc caused the current directory to change.
    10. That's by design and is correct behavior, if one uses relative paths.

  12. #11
    Uranium Lounger
    Join Date
    Dec 2000
    Location
    Los Angeles Area, California, USA
    Posts
    7,453
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Includetext Field & Relative Paths (Word 2000/SR-3)

    I agree that's what happens. In your step 3, if you open the file from Windows Explorer, & it is not your default Documents folder, update fields produces an error. This may be by design, but I don't know why it's a good design. If, in your example, you use relative hyperlinks instead of Includetext fields, the hyperlink will work as long as you maintain the same relative folder structure, regardless of whether Word current folder is changed or not. I don't see why Includetext fields couldn't have been designed similarly.

  13. #12
    Plutonium Lounger
    Join Date
    Nov 2001
    Posts
    10,550
    Thanks
    0
    Thanked 7 Times in 7 Posts

    Re: Includetext Field & Relative Paths (Word 2000/SR-3)

    I'm no expert with fields, but could you do something with the { Filename p } field and a quote field or two to extract the path to the current file and use that in your IncludeText field?

    StuartR

  14. #13
    Uranium Lounger
    Join Date
    Dec 2000
    Location
    Los Angeles Area, California, USA
    Posts
    7,453
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Includetext Field & Relative Paths (Word 2000/SR-3)

    Thanks for the idea, Stuart. But I can't think of a way to get the path of another document with a field in the current document. It would be nice to be able to use a full path in the target document minus the document name like

    { includetext "{ quote { = { FILENAME p } - { FILENAME } + source.doc } }" }

    but unfortunately, I can't think of a way to break up or subtract part of a string in a field. I haven't seen anything in the MS Knowledge Base or any of the newsgroups either.

  15. #14
    Super Moderator
    Join Date
    May 2002
    Location
    Canberra, Australian Capital Territory, Australia
    Posts
    3,894
    Thanks
    0
    Thanked 188 Times in 172 Posts

    Re: Includetext Field & Relative Paths (Word 2000/SR-3)

    Hi Stuart,

    Unfortuantely, there's no way short of a macro to extract the path. {Filename p} returns the filename and path. Since you'd be running the macro in the target document, you'd then need to discard the filename, which is easy enough. Then you'd need to convert the path backslashes to double backslashes - because that's how they have to be input in the field. Finally, extract the source file's name (from the previous includefield statement?) and add that to the end of the modified path and paste the lot back into the original includefield without upsetting bookmarks & switches.

    So, now that you know what's involved, care to give it a try? Or maybe there's a better way - I'm not sure anything's gained by using {Filename p} in the macro.

    Cheers
    Cheers,

    Paul Edstein
    [MS MVP - Word]

  16. #15
    Super Moderator
    Join Date
    May 2002
    Location
    Canberra, Australian Capital Territory, Australia
    Posts
    3,894
    Thanks
    0
    Thanked 188 Times in 172 Posts

    Re: Includetext Field & Relative Paths (Word 2000/SR-3)

    Hi Phil,

    I tried bookmarking just the path part of the string returned via {filename p}, but it get's clobbered as soon as {filename p} is updated, and I couldn't include the drive letter without selecting the whole field.

    Cheers
    Cheers,

    Paul Edstein
    [MS MVP - Word]

Page 1 of 3 123 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
  •