Home |
Search |
Today's Posts |
#1
|
|||
|
|||
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
|
|||
|
|||
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
|
|||
|
|||
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
|
|||
|
|||
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
|
|||
|
|||
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
|
|||
|
|||
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
|
|||
|
|||
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
|
|||
|
|||
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 | |
|
|
Similar Threads | ||||
Thread | Forum | |||
How do I insert and path to find my document in word? | Microsoft Word Help | |||
Linked Objects and path names | Microsoft Word Help | |||
relative path within includetext | Mailmerge | |||
file name and path footer? | Microsoft Word Help | |||
Merge Data Source path | Mailmerge |