Home |
Search |
Today's Posts |
#1
Posted to microsoft.public.word.mailmerge.fields
|
|||
|
|||
Mailmerge field result to insert word document
I have a my data source for mailing customers and once merged the «EntryID»
show ##### which is the customers unique .doc file name. What I need to then get word to do is instead of showing this number is to find the relating .doc file and insert the text from it. Is this possible? |
#2
Posted to microsoft.public.word.mailmerge.fields
|
|||
|
|||
Mailmerge field result to insert word document
You could use
{INCLUDETEXT "D:\\Path\\{Mergefield EntryID}"} OR {INCLUDETEXT "D:\\Path\\{Mergefield EntryID}.doc"} Depending on what is in the EntryID field -- Graham Mayor - Word MVP My web site www.gmayor.com Word MVP web site http://word.mvps.org "Primus" wrote in message ... I have a my data source for mailing customers and once merged the «EntryID» show ##### which is the customers unique .doc file name. What I need to then get word to do is instead of showing this number is to find the relating .doc file and insert the text from it. Is this possible? |
#3
Posted to microsoft.public.word.mailmerge.fields
|
|||
|
|||
Mailmerge field result to insert word document
Hi Graham,
Thanks for the reply, I have tried various versions of what you suggested but just keep getting text after the entry number: 69703{ INCLUDETEXT "Q:\\BookData\\Editor\\Entries{Mergefield EntryID}.doc" } 69703{ INCLUDETEXT "Q:\\BookData\\Editor\\Entries{Mergefield EntryID}" } 69703{ INCLUDETEXT "Q:\BookData\Editor\Entries{Mergefield EntryID}.doc" } 69703{ INCLUDETEXT "Q:\BookData\Editor\Entries{Mergefield EntryID}" } Should I omit anything from the code? "Graham Mayor" wrote: You could use {INCLUDETEXT "D:\\Path\\{Mergefield EntryID}"} OR {INCLUDETEXT "D:\\Path\\{Mergefield EntryID}.doc"} Depending on what is in the EntryID field -- Graham Mayor - Word MVP My web site www.gmayor.com Word MVP web site http://word.mvps.org "Primus" wrote in message ... I have a my data source for mailing customers and once merged the «EntryID» show ##### which is the customers unique .doc file name. What I need to then get word to do is instead of showing this number is to find the relating .doc file and insert the text from it. Is this possible? . |
#4
Posted to microsoft.public.word.mailmerge.fields
|
|||
|
|||
Mailmerge field result to insert word document
Press Alt+F9 to toggle off the display of the field codes (and maybe F9 to
update the fields) -- Hope this helps. Please reply to the newsgroup unless you wish to avail yourself of my services on a paid consulting basis. Doug Robbins - Word MVP, originally posted via msnews.microsoft.com "Primus" wrote in message ... Hi Graham, Thanks for the reply, I have tried various versions of what you suggested but just keep getting text after the entry number: 69703{ INCLUDETEXT "Q:\\BookData\\Editor\\Entries{Mergefield EntryID}.doc" } 69703{ INCLUDETEXT "Q:\\BookData\\Editor\\Entries{Mergefield EntryID}" } 69703{ INCLUDETEXT "Q:\BookData\Editor\Entries{Mergefield EntryID}.doc" } 69703{ INCLUDETEXT "Q:\BookData\Editor\Entries{Mergefield EntryID}" } Should I omit anything from the code? "Graham Mayor" wrote: You could use {INCLUDETEXT "D:\\Path\\{Mergefield EntryID}"} OR {INCLUDETEXT "D:\\Path\\{Mergefield EntryID}.doc"} Depending on what is in the EntryID field -- Graham Mayor - Word MVP My web site www.gmayor.com Word MVP web site http://word.mvps.org "Primus" wrote in message ... I have a my data source for mailing customers and once merged the «EntryID» show ##### which is the customers unique .doc file name. What I need to then get word to do is instead of showing this number is to find the relating .doc file and insert the text from it. Is this possible? . |
#5
Posted to microsoft.public.word.mailmerge.fields
|
|||
|
|||
Mailmerge field result to insert word document
Hi Primus,
It appears you've omitted the final path separator from your field code. Before executing the merge it should read: { INCLUDETEXT "Q:\\BookData\\Editor\\Entries\\{Mergefield EntryID}.doc" } -- Cheers macropod [Microsoft MVP - Word] "Primus" wrote in message ... Hi Graham, Thanks for the reply, I have tried various versions of what you suggested but just keep getting text after the entry number: 69703{ INCLUDETEXT "Q:\\BookData\\Editor\\Entries{Mergefield EntryID}.doc" } 69703{ INCLUDETEXT "Q:\\BookData\\Editor\\Entries{Mergefield EntryID}" } 69703{ INCLUDETEXT "Q:\BookData\Editor\Entries{Mergefield EntryID}.doc" } 69703{ INCLUDETEXT "Q:\BookData\Editor\Entries{Mergefield EntryID}" } Should I omit anything from the code? "Graham Mayor" wrote: You could use {INCLUDETEXT "D:\\Path\\{Mergefield EntryID}"} OR {INCLUDETEXT "D:\\Path\\{Mergefield EntryID}.doc"} Depending on what is in the EntryID field -- Graham Mayor - Word MVP My web site www.gmayor.com Word MVP web site http://word.mvps.org "Primus" wrote in message ... I have a my data source for mailing customers and once merged the «EntryID» show ##### which is the customers unique .doc file name. What I need to then get word to do is instead of showing this number is to find the relating .doc file and insert the text from it. Is this possible? . |
#6
Posted to microsoft.public.word.mailmerge.fields
|
|||
|
|||
Mailmerge field result to insert word document
Ok if I update the field I still keep getting "Error! Not a valid filename."
I have the word document 69703.doc in the following path "Q:\BookData\Editor\Entries\69703.doc" if I paste this in to windows explorer it opens up the word document so I know it's a valid filename/path. BEFORE MERGE EntryID{ INCLUDETEXT "Q:\\BookData\\Editor\\Entries\\{Mergefield EntryID}.doc" } AFTER MERGE 69703{ INCLUDETEXT "Q:\\BookData\\Editor\\Entries\\{Mergefield EntryID}.doc" } I don't see that I'm missing anything, or should I be putting this code into the EntryID date itself? "macropod" wrote: Hi Primus, It appears you've omitted the final path separator from your field code. Before executing the merge it should read: { INCLUDETEXT "Q:\\BookData\\Editor\\Entries\\{Mergefield EntryID}.doc" } -- Cheers macropod [Microsoft MVP - Word] "Primus" wrote in message ... Hi Graham, Thanks for the reply, I have tried various versions of what you suggested but just keep getting text after the entry number: 69703{ INCLUDETEXT "Q:\\BookData\\Editor\\Entries{Mergefield EntryID}.doc" } 69703{ INCLUDETEXT "Q:\\BookData\\Editor\\Entries{Mergefield EntryID}" } 69703{ INCLUDETEXT "Q:\BookData\Editor\Entries{Mergefield EntryID}.doc" } 69703{ INCLUDETEXT "Q:\BookData\Editor\Entries{Mergefield EntryID}" } Should I omit anything from the code? "Graham Mayor" wrote: You could use {INCLUDETEXT "D:\\Path\\{Mergefield EntryID}"} OR {INCLUDETEXT "D:\\Path\\{Mergefield EntryID}.doc"} Depending on what is in the EntryID field -- Graham Mayor - Word MVP My web site www.gmayor.com Word MVP web site http://word.mvps.org "Primus" wrote in message ... I have a my data source for mailing customers and once merged the «EntryID» show ##### which is the customers unique .doc file name. What I need to then get word to do is instead of showing this number is to find the relating .doc file and insert the text from it. Is this possible? . . |
#7
Posted to microsoft.public.word.mailmerge.fields
|
|||
|
|||
Mailmerge field result to insert word document
Hi Primus,
You've got the field code display toggled to 'on'. Press Alt-F9 to toggle it off again. Alternatively (or as well), embed your INCLUDETEXT text field in the mailmerge main document inside a QUOTE field, thus: {QUOTE{ INCLUDETEXT "Q:\\BookData\\Editor\\Entries\\{Mergefield EntryID}.doc" }} That will cause Word to unlink the field and display its output regardless of the field code toggle state when the mailmerge is run. -- Cheers macropod [Microsoft MVP - Word] "Primus" wrote in message ... Ok if I update the field I still keep getting "Error! Not a valid filename." I have the word document 69703.doc in the following path "Q:\BookData\Editor\Entries\69703.doc" if I paste this in to windows explorer it opens up the word document so I know it's a valid filename/path. BEFORE MERGE EntryID{ INCLUDETEXT "Q:\\BookData\\Editor\\Entries\\{Mergefield EntryID}.doc" } AFTER MERGE 69703{ INCLUDETEXT "Q:\\BookData\\Editor\\Entries\\{Mergefield EntryID}.doc" } I don't see that I'm missing anything, or should I be putting this code into the EntryID date itself? "macropod" wrote: Hi Primus, It appears you've omitted the final path separator from your field code. Before executing the merge it should read: { INCLUDETEXT "Q:\\BookData\\Editor\\Entries\\{Mergefield EntryID}.doc" } -- Cheers macropod [Microsoft MVP - Word] "Primus" wrote in message ... Hi Graham, Thanks for the reply, I have tried various versions of what you suggested but just keep getting text after the entry number: 69703{ INCLUDETEXT "Q:\\BookData\\Editor\\Entries{Mergefield EntryID}.doc" } 69703{ INCLUDETEXT "Q:\\BookData\\Editor\\Entries{Mergefield EntryID}" } 69703{ INCLUDETEXT "Q:\BookData\Editor\Entries{Mergefield EntryID}.doc" } 69703{ INCLUDETEXT "Q:\BookData\Editor\Entries{Mergefield EntryID}" } Should I omit anything from the code? "Graham Mayor" wrote: You could use {INCLUDETEXT "D:\\Path\\{Mergefield EntryID}"} OR {INCLUDETEXT "D:\\Path\\{Mergefield EntryID}.doc"} Depending on what is in the EntryID field -- Graham Mayor - Word MVP My web site www.gmayor.com Word MVP web site http://word.mvps.org "Primus" wrote in message ... I have a my data source for mailing customers and once merged the «EntryID» show ##### which is the customers unique .doc file name. What I need to then get word to do is instead of showing this number is to find the relating .doc file and insert the text from it. Is this possible? . . |
#8
Posted to microsoft.public.word.mailmerge.fields
|
|||
|
|||
Mailmerge field result to insert word document
Partly solved:
The following is now working for me as long at the { MERGEFIELD EntyrID}.doc resided in the Q:\\BookData\\Editor\\Entries\\ folder { INCLUDETEXT "Q:\\BookData\\Editor\\Entries\\{ MERGEFIELD EntryID }.doc" \* MERGEFORMAT } However I need the INCLUDETEXT command to look at all the Subfolders contained within the Entries folder and there are hundreds of these! |
#9
Posted to microsoft.public.word.mailmerge.fields
|
|||
|
|||
Mailmerge field result to insert word document
There is no way to do that with fields. You can only look in the defined
folder. It's a fixed path. If your documents are stored in a variety of sub folders then you are going to have to tell the field which folder to look in for the particular document. How you would do this rather depends on how your filing system is arranged and whether the folder can be determined from the data source. For example you might be able to use the same or another field to get the path { INCLUDETEXT "Q:\\BookData\\Editor\\Entries\\{MERGEFIELD Client}\\{ MERGEFIELD EntryID}.doc" } It is either that or copy all the documents used by the merge to the same folder location. -- Graham Mayor - Word MVP My web site www.gmayor.com Word MVP web site http://word.mvps.org "Primus" wrote in message ... Partly solved: The following is now working for me as long at the { MERGEFIELD EntyrID}.doc resided in the Q:\\BookData\\Editor\\Entries\\ folder \* MERGEFORMAT } However I need the INCLUDETEXT command to look at all the Subfolders contained within the Entries folder and there are hundreds of these! |
#10
Posted to microsoft.public.word.mailmerge.fields
|
|||
|
|||
Mailmerge field result to insert word document
Ideally, your data source would actually store the complete pathname of
each file, rather than the "filename" part. How to do that would depend very much on your data source and your ability to program it - you might for example be able to add a column to the data source and run a macro to populate it with all the relevant file pathnames prior to merging. An alternative that /may/ work given that your file names are very simple is a. to create a document - let's call it "c:\a\list.htm" - that lists each file path, bookmarked with the filename in the format needed by the merge. b. to use another INCLUDETEXT to translate the filename into the filepath, e.g. like this: { QUOTE { INCLUDETEXT "{ INCLUDETEXT "c:\\a\\list.htm" "{ MERGEFIELD EntryID }doc" }" } So let's assume that you have an EntryID of 12345, and the corresponding file is at c:\folder1\folder2\12345.doc Before the merge you would run a macro that would create a file which contained a list of pathnames, including c:\\folder1\\folder2\\12345.doc This pathname would be bookmarked with the name "12345doc" Then you do the merge. For the record where EntryID is 12345, "{ MERGEFIELD EntryID }doc" is 12345doc "{ INCLUDETEXT "c:\\a\\list.htm" "12345doc" }" is "c:\\folder1\\folder2\\12345.doc" so we then { QUOTE { INCLUDETEXT "c:\\folder1\\folder2\\12345.doc" } } which should do what you need. A macro that can build such a list is as follows. However, it depends on your filenames being simple and consistent - e.g., all the files have to have the same extension, and must convert easily into valid bookmark names. You'll find notes on how to install macros etc. on Graham's page at http://www.gmayor.com/installing_macro.htm Sub createFileList() ' creates and populates ' an HTML file that can be used to map ' file names to file pathnames for a ' Word MailMerge ' This is not a general-purpose routine! ' For it to work, the file names have to be ' simple enough that removing "." characters ' turns them into valid bookmark names. ' In the VB Editor, with this macro open, ' use Tools-References to locate and check ' "Microsoft Scripting Runtime" ' You could produce the output ' using the "File System Object" if you ' prefer that to the old VB OPEN/PRINT/CLOSE ' commands. ' Also needs error handling! ' for example, a file called ' c:\folder1\folder2\filename.doc ' will be listed as ' pa name="filenamedoc"c:\\folder1\\folder2\\filename. doc/a/p ' In the mailmerge, if the "filename" part ' of the name is in a column called "fn", ' all the files to be included are ".doc" files ' and the HTML file is called c:\a\list.htm, ' it should be possible to include that file ' using the following nested field codes: ' { INCLUDETEXT "{ INCLUDETEXT "c:\\a\\list.htm" "{ MERGEFIELD fn }doc" } } ' HTML was chosen as the output format because it ' is easier to produce than a Word .doc file ' Set this to the pathname of the ' top folder in your folder tree Const topFolderName As String = "c:\a" ' Set this to the pathname of the ' HTML file that your Mail Merge ' Main document will reference. Const listFileName As String = "c:\a\list.htm" Dim lngFileNumber As Long Dim objFile As Scripting.File Dim objFiles As Scripting.Files Dim objFolder As Scripting.Folder Dim objFSO As Scripting.FileSystemObject Set objFSO = CreateObject("Scripting.FileSystemObject") Set objFolder = objFSO.GetFolder(topFolderName) lngFileNumber = FreeFile Open listFileName For Output As lngFileNumber Print #lngFileNumber, "htmlbody" Set objFiles = objFolder.Files For Each objFile In objFiles Call addFileToList(objFile, lngFileNumber) Next Set objFiles = Nothing Call processSubFolders(objFolder, lngFileNumber) finish: Print #lngFileNumber, "/body/html" Close #lngFileNumber Set objFolder = Nothing Set objFSO = Nothing End Sub Sub processSubFolders(objFolder As Scripting.Folder, lngFileNumber As Long) Dim objFile As Scripting.File Dim objFiles As Scripting.Files Dim objFolders As Scripting.Folders Dim objSubFolder As Scripting.Folder Set objFolders = objFolder.SubFolders For Each objSubFolder In objFolders Set objFiles = objSubFolder.Files For Each objFile In objFiles Call addFileToList(objFile, lngFileNumber) Next Call processSubFolders(objSubFolder, lngFileNumber) Next Set objFolders = Nothing End Sub Sub addFileToList(objFile As Scripting.File, _ lngFileNumber As Long) Print #lngFileNumber, "pa name=""" & Replace(objFile.Name, ".", "") & """" & Replace(objFile.Path, "\", "\\") & "/a/p" End Sub FWIW, the only other way I could think of that had some potential to do this would be to manually drag links (Windows shortcuts) for every document to a single folder, then include all the files from that folder, adjusting the file name as necessary (e.g. instead of 12345.doc, you might need to include 12345.doc.lnk ) Unfortunately, when I tried this, Word seems to treat the .lnk files or the linked files as text files and does not open them as Word files. Peter Jamieson http://tips.pjmsn.me.uk On 18/12/2009 13:46, Primus wrote: Partly solved: The following is now working for me as long at the { MERGEFIELD EntyrID}.doc resided in the Q:\\BookData\\Editor\\Entries\\ folder { INCLUDETEXT "Q:\\BookData\\Editor\\Entries\\{ MERGEFIELD EntryID }.doc" \* MERGEFORMAT } However I need the INCLUDETEXT command to look at all the Subfolders contained within the Entries folder and there are hundreds of these! |
Reply |
Thread Tools | |
Display Modes | |
|
|
Similar Threads | ||||
Thread | Forum | |||
Formatting a field result in Word | Mailmerge | |||
limiting mailmerge result | Mailmerge | |||
Can you insert a mailmerge field but not print it? | Mailmerge | |||
copy a field result into a footer of a document | Microsoft Word Help | |||
Result in form field to generate comment in next field | Microsoft Word Help |