Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

How can I include the current path in INCLUDETEXT? 1

Status
Not open for further replies.

sauroneru

Technical User
Mar 5, 2003
8
US
I'm using INCLUDETEXT fields to insert many subdocuments into a master document. All subdocuments and master documents are in the same directory, which changes every once in a while. I'd like to tell INCLUDETEXT to use the "Chapter1.doc" file in the same directory as the master document - is this possible?
 
Unfortunately that doesn't work. Word apparently uses the working directory as the default, not the directory that the main document is stored in. If I manually open the main document using Word's Open dialog, Word will change its default directory. But it won't change its default directory if I open the file by double clicking it in Windows Explorer. Not a big deal, I was just wondering if there was some variable to insert in the fields that returned the document's path.

{includetext "Path File1.doc" \!}
 
Yep, that's the INCLUDETEXT command. In summary:

- Now I use {INCLUDETEXT "C:\\Doc1.doc"}, which works great but I'd like to refrain from using absolute paths.
- Using {INCLUDETEXT "Doc1.doc"} uses whatever current directory Word is using (My documents at startup, or the directory of the last opened file through the Open GUI) rather than the directory of the main file.
- I was just wondering if there was a variable/field function that returned the path to the current document, so maybe I could use something like {INCLUDETEXT PATH Doc1.doc}, but the more I look at the field codes the more I think this isn't possible. Thanks for your help!
 
I don't believe there's any way to avoid using absolute paths with INCLUDETEXT fields. Even if you omit the path altogether, Word somehow 'remembers' the original path.

If you need to change the drivename or folder(s) containing the source document(s), the path needs to be updated - regardless of whether the target document has moved. I've written a macro to expedite this for INCLUDETEXT, INCLUDEPICTURE, LINK, HYPERLINK and RD fields. You can download the document it's in at:
Instructions for use are included in the document.

Cheers
 
That's a wonderful macro and exactly what I was looking for. It's also very clearly written and I'll certainly refer to it the next time I get the urge to learn Word macro basics. Thanks a lot!
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top