relative path within includetext

G

George Lagger

i need to insert text from one file to another with an "includetext" field,
but doing so i have to specify the full path to the file. When both files
migrate to some other folders, the path obviously changes. Can i use a
'relative' form of the path (smth like ActiveDocument.Path in VB) in the
"includetext" field?
 
E

Ed Kuzemchak

George,

(I have the same problem, and I have found this partial solution, which I
admit is not optimal)

Word supports relative paths in {includetext} in a funny way - they are
relative to the current working directory of MS Word. One way of setting
the working directory is to do a File/Open and browse to the directory where
your .doc lives, then hit "Cancel". An easier way is to open your .doc
using File/Open in the first place.

Then, you can write {includetext "foo.txt"} and it will pick up foo.txt from
the same directory as your .doc. Or even {includetext "..\\foo.txt"}.

Careful though, any use of the File/Open dialog will cause the working
directory to get reset. Before updating links with F9, be sure to use
File/Open to reset the working dir.

Not great, but it worked for me.
 
G

George Lagger

Ed, thank you for your attention to the problem

I also found a solution implying a little bit of VB programming:
***
Private Sub Document_Open()
ThisDocument.CustomDocumentProperties("Path") = ThisDocument.Path
End Sub
***

On opening the main document this macro creates a property "Path" (and fills
it with the path to your main doc), which may be used in the includetext
field, e.g.

{ INCLUDETEXT "{DOCPROPERTY Path}\\FileToInclude.doc" }

where "FileToInclude.doc" is the Filename (without path) of your file with
the text to include.

It works (at least in Word 2003), although the path contains single
backslashes instead of doubles.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top