Home |
Search |
Today's Posts |
#1
Posted to microsoft.public.word.mailmerge.fields
|
|||
|
|||
How to make mail merge independent from source file path?
When moving the files that have merge fields to another location or media, of
course with the source file, the path changes and the word file wouldn't be able to locate the source new location. How can I make the mail merge path independent, so I can burn both on CD, for instance, and keep the merge feature. |
#2
Posted to microsoft.public.word.mailmerge.fields
|
|||
|
|||
How to make mail merge independent from source file path?
The only way to do it as far as I know is
a. disconnect the mail merge main document from its data source b. use an AutoOpen macro to connect it again. The macro can discover the document's folder. Unfortunately, in order to do that, c. the destination system has to be prepared according to the following KB article: http://support.microsoft.com/default...b;en-us;825765 d. the destination system also has to be set up so that the AutoOpen macro will run. Even then, you will probably have difficulty getting the merge to work /directly/ from the CD. Generally speaking, with Word, the user needs to copy the files off the CD and onto a writable disk before Word will work properly. You can do (a) using e.g. ActiveDocument.MailMerge.MainDocumentType = wdNotAMergeDocument in th VB Editor's immediate window You will lose information about the /type/ of merge, the location of the data source, any sort/filter options, and the merge destination, but the merge field codes will remain. You can find out what Word thinks the file name, connection string and query are using the following in the immediate window: print ActiveDocument.Mailmerge.DataSource.Name print ActiveDocument.Mailmerge.DataSource.ConnectString print ActiveDocument.Mailmerge.DataSource.QueryString You can (probably!) do (b) using something like the following macro, but you will need to changes stuff depending on the type of data source, and the code that creates the full path name of the data source probably needs to be more robust: Sub AutoOpen() Dim strDataSource As String Dim strConnection As String Dim strQuery As String ' this is a simple example for a data source which is a Word document ' set this to be the file name of your data source strDataSource = "kt.doc" ' set this to be the connection string for your data source 'strConnection = "" ' set this to be the query for your data source ' strQuery = "" With ActiveDocument strDataSource = .Path & "\" & strDataSource ' for a Word document as data source, we just need the path name With .MailMerge .OpenDataSource _ Name:=strDataSource ' use the type you need .MainDocumentType = wdFormLetters ' use the destination you need .Destination = wdSendToNewDocument ' NB the above code does not execute the merge. End With End With End Sub Peter Jamieson "Mohammad Fouz Salah" Mohammad Fouz wrote in message ... When moving the files that have merge fields to another location or media, of course with the source file, the path changes and the word file wouldn't be able to locate the source new location. How can I make the mail merge path independent, so I can burn both on CD, for instance, and keep the merge feature. |
Reply |
Thread Tools | |
Display Modes | |
|
|
Similar Threads | ||||
Thread | Forum | |||
Word 2000 mail merge documents won't save Access 2000 data source | Mailmerge | |||
Editing Mail Merge Recipients | Mailmerge | |||
Using HTML file as data source for Mail Merge | Mailmerge | |||
word cannot open file as a data or header source bec it is a mail merge main doc | Mailmerge | |||
DotNet Data Table as Mail Merge Data Source | Mailmerge |