Problem: Template Field Code unlinks automatically

M

Mo

Hi,

the following is a solution to in a template file link to another file which
is in a location relative to the template.

{HYPERLINK "{template \p}\\..\\..\\Disbursement%20Request.docx"}

The problem is that when the template is saved and reopened, the template
field code has changed to a static [path]\normal.dotm. It seems like Word
2007 automatically unlinks the template field already at time of Save of the
template (I think so because the template name is set to normal) I would like
the path and filename to translate first when a new document is created from
the template.

I have unchecked "Update links on save" under "Web options".

Can this be solved?

Thanks
P
 
P

Peter Jamieson

I do not know of a simple way to achieve this without code, but if your
template is a Word 2007 template (.dotx), the following approach /may/
be workable:
The overview is:
a. use a field that generates an error instead of the field you want.
Th is field should be preserved the first time you save it
b. save the .dotx
c. edit the document.xml file contained in the .dotx to change the
text of the field code to the one you want

So, e.g....
a. Add the Hyperlink field(s) you want immediately before saving the
..dotx, using ctrl-F9 to insert the special field code braces. But
instead of using { template \p }, insert e.g. { CHANGEME } (you must not
have used a bookmark called CHANGEME anywhere for this to work). SO you
have e.g.

{ HYPERLINK "{ CHANGEME }followed by the other text you want" }

Select each of these hyperlinks and press F9 to update the field
b. save and close your .dotx - let's say it is mytemplate.dotx
c. in Windows Explorer/My computer/whatever, locate mytemplate.dotx
and make a backup copy.
d. rename mytemplate.dotx to mytemplate.zip
e. open the .zip. Open the word folder inside it. Drag the
document.xml file to a folder and open it, e.g. in Notepad.
f. search for CHANGEME and change it to TEMPLATE \p
g. copy/paste the document.xml back into that word folder within the
zip file
h. close any windows that show the contents of the zip file
i. rename the .zip back to a .dotx
j. open the template, or a document based on it
k. select and update the HYPERLINK fields.

Trouble is that even if you get it to work,
a. this is probably not how Word "expects" things to be, so all sorts
of unexpected problems may occur or a Word update might invalidate this
approach, especially if someone thinks it is a security risk
b. each time you save your .dotx you will probably need to redo this,
so if you need to do it a lot you will probably need to write some code
to help you anyway.

Peter Jamieson

http://tips.pjmsn.me.uk
Visit Londinium at http://www.ralphwatson.tv
 
M

Mo

Thank you for your effort. But as you state, it might not be a solution to
rely on.
/p

Peter Jamieson said:
I do not know of a simple way to achieve this without code, but if your
template is a Word 2007 template (.dotx), the following approach /may/
be workable:
The overview is:
a. use a field that generates an error instead of the field you want.
Th is field should be preserved the first time you save it
b. save the .dotx
c. edit the document.xml file contained in the .dotx to change the
text of the field code to the one you want

So, e.g....
a. Add the Hyperlink field(s) you want immediately before saving the
..dotx, using ctrl-F9 to insert the special field code braces. But
instead of using { template \p }, insert e.g. { CHANGEME } (you must not
have used a bookmark called CHANGEME anywhere for this to work). SO you
have e.g.

{ HYPERLINK "{ CHANGEME }followed by the other text you want" }

Select each of these hyperlinks and press F9 to update the field
b. save and close your .dotx - let's say it is mytemplate.dotx
c. in Windows Explorer/My computer/whatever, locate mytemplate.dotx
and make a backup copy.
d. rename mytemplate.dotx to mytemplate.zip
e. open the .zip. Open the word folder inside it. Drag the
document.xml file to a folder and open it, e.g. in Notepad.
f. search for CHANGEME and change it to TEMPLATE \p
g. copy/paste the document.xml back into that word folder within the
zip file
h. close any windows that show the contents of the zip file
i. rename the .zip back to a .dotx
j. open the template, or a document based on it
k. select and update the HYPERLINK fields.

Trouble is that even if you get it to work,
a. this is probably not how Word "expects" things to be, so all sorts
of unexpected problems may occur or a Word update might invalidate this
approach, especially if someone thinks it is a security risk
b. each time you save your .dotx you will probably need to redo this,
so if you need to do it a lot you will probably need to write some code
to help you anyway.

Peter Jamieson

http://tips.pjmsn.me.uk
Visit Londinium at http://www.ralphwatson.tv

Hi,

the following is a solution to in a template file link to another file which
is in a location relative to the template.

{HYPERLINK "{template \p}\\..\\..\\Disbursement%20Request.docx"}

The problem is that when the template is saved and reopened, the template
field code has changed to a static [path]\normal.dotm. It seems like Word
2007 automatically unlinks the template field already at time of Save of the
template (I think so because the template name is set to normal) I would like
the path and filename to translate first when a new document is created from
the template.

I have unchecked "Update links on save" under "Web options".

Can this be solved?

Thanks
P
 

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