Well, there isn't a field code whose result is the value of an environment
variable so you do need another way to get the value into the INCLUDETEXT
field, so you will need some code (either VBA, or perhaps VBScript or some
such) to insert a value that Word can use. If you are using Automation, you
could consider
a. locating the INCLUDETEXT, e.g. using a bookmark, constructing the one
you want from scratch, and stuffing the INCLUDETEXT in (but in that case you
might as well just do the code to include the file unless you want the
INCLUDETEXT to be retained)
b. creating a Word document variable (via the Word object model) and
nesting a { DOCVARIABLE } field inside your INCLUDETEXT
c. creating a custom Word document property and nesting a { DOCPROPERTY }
field inside your INCLUDETEXT. An advantage of this approach may be that you
can create a DOCPROPERTY without using the Word object model. But it still
requires code of some kind and probably a third party dll which you might
need to distribute, so I'd try to do a solution based on automation. There's
an article at
The only other approach I can think of that would avoid automation (except
that the necessary field codes might not be updated when the document was
opened, would be to stuff the pathname into a text file with a known path
name, and retrieve it in Word using a DATABASE field, e.g. if you construct
a text file called c:\\a\\include.txt containing
pathname,dummy
c:\\pathtoinclude\\filename.doc,dummy
and use a database field such as
{ DATABASE \d "C:\\a\\include.txt" \c "" \s "SELECT pathname FROM
C:\\a\\include.txt" }
(the above works here with Word 2003 - it probably won't work with Word 2000
or earlier). A lot to go wrong there though.
Peter Jamieson