Reply
 
Thread Tools Display Modes
  #1   Report Post  
Peter Chambers
 
Posts: n/a
Default Is it possible to set dynamic path for docs that merge?

I would like to offer users of the document the chance to browse for a file
perhaps from a userform) that gets imported into the word document (Excel
file, text file etc).

I have tried using variables inside an INCLUDETEXT field or LINK field with
no success.

How can I acheive this goal?

Thank you all very much in advance,

Peter


  #2   Report Post  
Peter Jamieson
 
Posts: n/a
Default

It should be possible to use a variable inside an INCLUDETEXT, but
a. you may find that INCLUDETEXT wants any backslashes to be doubled up,
e.g.

"c:\\mydir\\myfile.doc"

rather than

"c:\mydir\myfile.doc"

b. you may run into trouble with LINK fields as they tend to muck around
with the pathname once you execute the LINK field. I hope INCLUDETEXT has
not gone the same way recently.

Peter Jamieson

"Peter Chambers" wrote in message
...
I would like to offer users of the document the chance to browse for a file
perhaps from a userform) that gets imported into the word document (Excel
file, text file etc).

I have tried using variables inside an INCLUDETEXT field or LINK field
with no success.

How can I acheive this goal?

Thank you all very much in advance,

Peter



  #3   Report Post  
Peter Chambers
 
Posts: n/a
Default

Thanks Peter.

Can I include environment variables though or is it another type of
variable? If so how do I create those and reference them?

\\%variable%

?
"Peter Jamieson" wrote in message
...
It should be possible to use a variable inside an INCLUDETEXT, but
a. you may find that INCLUDETEXT wants any backslashes to be doubled up,
e.g.

"c:\\mydir\\myfile.doc"

rather than

"c:\mydir\myfile.doc"

b. you may run into trouble with LINK fields as they tend to muck around
with the pathname once you execute the LINK field. I hope INCLUDETEXT has
not gone the same way recently.

Peter Jamieson

"Peter Chambers" wrote in message
...
I would like to offer users of the document the chance to browse for a
file perhaps from a userform) that gets imported into the word document
(Excel file, text file etc).

I have tried using variables inside an INCLUDETEXT field or LINK field
with no success.

How can I acheive this goal?

Thank you all very much in advance,

Peter





  #4   Report Post  
Peter Jamieson
 
Posts: n/a
Default

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

"Peter Chambers" wrote in message
...
Thanks Peter.

Can I include environment variables though or is it another type of
variable? If so how do I create those and reference them?

\\%variable%

?
"Peter Jamieson" wrote in message
...
It should be possible to use a variable inside an INCLUDETEXT, but
a. you may find that INCLUDETEXT wants any backslashes to be doubled up,
e.g.

"c:\\mydir\\myfile.doc"

rather than

"c:\mydir\myfile.doc"

b. you may run into trouble with LINK fields as they tend to muck around
with the pathname once you execute the LINK field. I hope INCLUDETEXT has
not gone the same way recently.

Peter Jamieson

"Peter Chambers" wrote in message
...
I would like to offer users of the document the chance to browse for a
file perhaps from a userform) that gets imported into the word document
(Excel file, text file etc).

I have tried using variables inside an INCLUDETEXT field or LINK field
with no success.

How can I acheive this goal?

Thank you all very much in advance,

Peter







  #5   Report Post  
Cindy M -WordMVP-
 
Posts: n/a
Default

Hi Peter,

I would like to offer users of the document the chance to browse for a file
perhaps from a userform) that gets imported into the word document (Excel
file, text file etc).

I have tried using variables inside an INCLUDETEXT field or LINK field with
no success.

Just to be su we're NOT discussing mail merge, right?

What you want is to let the user enter or choose a file path, and you want to
put that into an IncludeText or a LINK field? And do you double the
backslashes in the path before you use it in the field?

If that's not what's been tripping you up, could you please describe in more
detail HOW it's not working. And give us an example. Also, please tell us the
version of Word.

Cindy Meister
INTER-Solutions, Switzerland
http://homepage.swissonline.ch/cindymeister (last update Jun 8 2004)
http://www.word.mvps.org

This reply is posted in the Newsgroup; please post any follow question or
reply in the newsgroup and not by e-mail :-)



  #6   Report Post  
Peter Chambers
 
Posts: n/a
Default

Thanks Cindy - let me try to clarify further the ideal sequence of events:

1. When opening a word document the user will be presented with a userform
which will include an area where they will browse for a file (Excel, text),
the contents of which are to be included in the word document at a
particular point.
2. Once that file (and consequently path also has been specified by the
user, I would like to display the contents of that file in the word document
and I thought the only way to do that was to use INCLUDETEXT or LINK fields
but I could not figure out how to avoid typing in a static path in the
INCLUDeTEXT ro LINK field statements. I would like the file (and path) that
the user selected to be dynamically used as the source for the INCLUDETEXT
or LINK fields (unless there is a better way?)

{ INCLUDETEXT "I need the path and file that the user selectewd in a
userform to be represented here" }

Users of the document will have a mixture of Office XP and 2003. I am
running Word 2003.

Thank you!

"Cindy M -WordMVP-" wrote in message
news:VA.0000aaa1.008455ce@speedy...
Hi Peter,

I would like to offer users of the document the chance to browse for a
file
perhaps from a userform) that gets imported into the word document (Excel
file, text file etc).

I have tried using variables inside an INCLUDETEXT field or LINK field
with
no success.

Just to be su we're NOT discussing mail merge, right?

What you want is to let the user enter or choose a file path, and you want
to
put that into an IncludeText or a LINK field? And do you double the
backslashes in the path before you use it in the field?

If that's not what's been tripping you up, could you please describe in
more
detail HOW it's not working. And give us an example. Also, please tell us
the
version of Word.

Cindy Meister
INTER-Solutions, Switzerland
http://homepage.swissonline.ch/cindymeister (last update Jun 8 2004)
http://www.word.mvps.org

This reply is posted in the Newsgroup; please post any follow question or
reply in the newsgroup and not by e-mail :-)



  #7   Report Post  
Peter Jamieson
 
Posts: n/a
Default

Judging by your response to Cindy, I'd go for (b), or possibly (a).

Peter Jamieson

"Peter Jamieson" wrote in message
...
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

"Peter Chambers" wrote in message
...
Thanks Peter.

Can I include environment variables though or is it another type of
variable? If so how do I create those and reference them?

\\%variable%

?
"Peter Jamieson" wrote in message
...
It should be possible to use a variable inside an INCLUDETEXT, but
a. you may find that INCLUDETEXT wants any backslashes to be doubled up,
e.g.

"c:\\mydir\\myfile.doc"

rather than

"c:\mydir\myfile.doc"

b. you may run into trouble with LINK fields as they tend to muck around
with the pathname once you execute the LINK field. I hope INCLUDETEXT
has not gone the same way recently.

Peter Jamieson

"Peter Chambers" wrote in message
...
I would like to offer users of the document the chance to browse for a
file perhaps from a userform) that gets imported into the word document
(Excel file, text file etc).

I have tried using variables inside an INCLUDETEXT field or LINK field
with no success.

How can I acheive this goal?

Thank you all very much in advance,

Peter









  #8   Report Post  
Cindy M -WordMVP-
 
Posts: n/a
Default

Hi Peter,

1. When opening a word document the user will be presented with a userform
which will include an area where they will browse for a file (Excel, text),
the contents of which are to be included in the word document at a
particular point.
2. Once that file (and consequently path also has been specified by the
user, I would like to display the contents of that file in the word document
and I thought the only way to do that was to use INCLUDETEXT or LINK fields
but I could not figure out how to avoid typing in a static path in the
INCLUDeTEXT ro LINK field statements. I would like the file (and path) that
the user selected to be dynamically used as the source for the INCLUDETEXT
or LINK fields (unless there is a better way?)

Yes, I understood you correctly, I just don't follow what your problem is. Can
you state the exact problem that's preventing you from proceeding?

You get the path from the user, and you substitute it in the field code for the
one that's already there. If you don't want to put it directly in the field
code, then put it in a document VARIABLE object or a CustomProperty object,
then use a DocVariable (or DocProperty) field to link that into the other field
code.

{ INCLUDETEXT "I need the path and file that the user selectewd in a
userform to be represented here" }

Users of the document will have a mixture of Office XP and 2003. I am
running Word 2003.


Cindy Meister
INTER-Solutions, Switzerland
http://homepage.swissonline.ch/cindymeister (last update Jun 8 2004)
http://www.word.mvps.org

This reply is posted in the Newsgroup; please post any follow question or reply
in the newsgroup and not by e-mail :-)

Reply
Thread Tools
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
How do I insert and path to find my document in word? ME Microsoft Word Help 2 February 23rd 05 09:53 PM
Linked Objects and path names Colin Higbie Microsoft Word Help 7 January 30th 05 08:51 PM
relative path within includetext George Lagger Mailmerge 2 January 27th 05 03:15 PM
file name and path footer? Legal Learning Microsoft Word Help 0 January 20th 05 04:25 PM
Merge Data Source path Peter Jamieson Mailmerge 0 November 25th 04 07:15 PM


All times are GMT +1. The time now is 07:50 AM.

Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 Microsoft Office Word Forum - WordBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Word"