INCLUDETEXT and virtual path

D

Deb

The INCLUDETEXT field has as its syntax as follows:

{INCLUDETEXT "path"}

THe help file instructs you to use double slashes to replace single slashes
separating directories. My question is, how to you enter relative paths? At
this point I can only enter absolute paths so that if the files move, the
links are broken. I want to always keep the source and the destination files
in the same directory but be able to move the entire set to another directory
without breaking links.

Thanks in advance for any help!
 
P

Peter Jamieson

1. Nothing much works very well unless you uncheck Word Tools|General|Web
Options|Files|Update links on save (or the Word 2007 equivalent)

2. You can't use "traditional" relative paths because the path is relative
to the active folder, which is not necessarily the same as the folder than
contains the document that contains the INLUDETEXT field.

3. You can however use a trick using a nested field. e.g. if you want to
include x.doc and it's in the same folder as the including document, try

{ INCLUDETEXT "{ filename /p}\\..\\x.doc" }

(where both sets of {} are the special field code braces you can insert
using ctrl-F9). You may need to have a way to re-execute this field before
it will do what you want after you move the files to a new folder.

You may also be able to use

{ INCLUDETEXT "{ filename /p}/../x.doc" }

if you prefer.
 
D

Deb

Thank you, Peter. That's marvelous!!!! ;-)

Peter Jamieson said:
1. Nothing much works very well unless you uncheck Word Tools|General|Web
Options|Files|Update links on save (or the Word 2007 equivalent)

2. You can't use "traditional" relative paths because the path is relative
to the active folder, which is not necessarily the same as the folder than
contains the document that contains the INLUDETEXT field.

3. You can however use a trick using a nested field. e.g. if you want to
include x.doc and it's in the same folder as the including document, try

{ INCLUDETEXT "{ filename /p}\\..\\x.doc" }

(where both sets of {} are the special field code braces you can insert
using ctrl-F9). You may need to have a way to re-execute this field before
it will do what you want after you move the files to a new folder.

You may also be able to use

{ INCLUDETEXT "{ filename /p}/../x.doc" }

if you prefer.
 
D

Deb

I think I may have jinxed myself. I tested this out by changing all my
INCLUDTEXT fields to a variant of this:

{ INCLUDETEXT "{FILENAME /p}/../REF_Things_to_Know_Line_4.doc"}

I updated and everything worked fine ..... UNTIL I moved all the files to a
new directory. Now after updating I get this:

Error! Not a valid filename.

I notice that you mentioned "You may need to have a way to re-execute this
field before it will do what you want after you move the files to a new
folder." What do you mean by this? Sounds like that may be the problem?

Thanks!
 
P

Peter Jamieson

I notice that you mentioned "You may need to have a way to re-execute this
field before it will do what you want after you move the files to a new
folder." What do you mean by this?

I mean that Word does not automatically update all fields when you open the
document. So if you move the document, you still have to re-execute the {
FILENAME /p } field and the INCLUDETEXT field before the results will appear
correctly. (And if you are moving the documents to a machine or logon with a
different copy of Word or different settings, you have to change those
settings - i.e. they are not carried around with the document).
Sounds like that may be the problem?

Well, it sounds as if that is what you have done. so I'm not so sure it /is/
the problem.

What I usually do in these cases is try to have a good look at the result of
each field - if you use Alt-F9 to display the field codes, then select the
one you want (e.g. { FILENAME /p }, then right-click and use Toggle Field
Codes on the popup menu, only that field should be toggled, so you should be
able to see its result.)

Also, if you have moved the document deep inside a folder hierarchy, you may
end up with problems if the total length of the path name exceeds 255
characters or some such.
 
D

Deb

Thanks, Peter.

I had moved the entire set to the root, so the 255 char limit wasn't in play.

I was able to get it to work using a different method; i.e.,

{INCLUDETEXT "c:\test.doc"}

and putting the absolute path in the Hyperlink code base found under
File...Properties. THat's a viable solution for this situation since the
ratio of source to target docs is about 10:1. The target doc is the only doc
that needs to be modified if I ever move the files.

And I bet there is a way to run a macro on a list of target files to change
their hyperlink base. If only I knew VBA. ;-)

Thanks so much for your help on this matter. I've flagged this thread as
"helpful."
 
P

Peter Jamieson

That's very interesting. I've never had much success with modifying the
hyperlink code base myself, and that kind of experience usually leads to the
"what am I doing differently" question.

Another thing to try to investigate more thoroughly one day... :)
 
K

KStrickland

Interesting, since I had a similar issue. I've got INCLUDETEXT statements
within complex IFs using COMPAREs, where I need to bring in detailed
instructions when certain conditions are met for various services. So far
I've got all of my text to be included in a separate document and am using
Bookmarks to control which pieces to bring into each area. So, I needed to be
able to have an easy way to manage version control (by keeping the Include
document at the same version as the main document). However, I don't want to
have to find and replace all of them, since I'll have several hundred when
done. I've figured out a pretty easy way to do this, which is what I think
you are trying to accomplish, as well.

First, near the beginning of the main document, I set the path and filename
using the following structure.
{SET var_IncludeFile "{HYPERLINK "C:\\path\\file.doc"}"} -- I just used the
insert Hyperlink menu and it resolved all of the double slashes, folders,
etc. ...

I display it for verification purposes for now: { var_IncludeFile }
I also have a macro set up to lock it, allow me to use a couple of
drop-downs for selection criteria, then a checkbox with another macro to
unlock it, select all (CTRL-A), update (F9), Find a header - just to get it
to unselect everything and put them at the beginning. Sorry for the detail,
but did want to indicate some other stuff is going on here...

Then, where I have my logic for including the text where needed like
{IF {=OR ({Compare <criteria> })} = 1 "{IncludeText "{var_IncludeFile}"
bookmark_name_for_this_piece } " ""}
+
Interesting thing I stumbled across that Peter already verified on a
different thread, is that the extra space following the close bracket after
the bookmark (where I've put the '+' allows hyperlinks within the bookmarked
text that's being included to work. If you don't have the extra space then
Word ignores the Hyperlink piece for some reason...

The other thing to mention, that you seem to have already run into, sort of,
is that the IncludeText builds external Links for your document. I kept
getting "Error! Invalid Filename" and finally realized that in my zest to get
organized for this approach, I moved the main document and the Included text
document to a new folder, which broke the links. I thought it was really
interesting (NOT) that everytime I tried to Update the IncludeText with
another variation of my approach, Word was kind enough to add an extra Link
for the same dang statement... So, I've had to clean up quite a few test
cases.... You may want to verify in 2003 under Edit, Links or in 2007 under
Windows, Prepare, Edit Links to see how many extras you have. Unfortunately,
I don't see an easy way to determine which one for the statement is correct.
You may need to delete all of them, and re-add them. I'm still working on
this part, so hopefully I can find a way to mechanize this process, since I
know when I move this to the SharePoint site we use, I'll have to rebuild
them all again... For some reason, all of the links are set to Manual, and
the options to automatically update are grayed out...

Hopefully, you will find this useful.
 

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