Home |
Search |
Today's Posts |
#1
Posted to microsoft.public.word.mailmerge.fields
|
|||
|
|||
How do I connect to a mail merge data base using a relative path?
How do I connect to a mail merge data base using a relative path?
|
#2
Posted to microsoft.public.word.mailmerge.fields
|
|||
|
|||
How do I connect to a mail merge data base using a relative path?
As far as I know you cannot do this without code, e.g. VBA code, because
a. Word always stores the pathnames of data sources as absolute path names b. in any case, Word treats relative path names as relative to the /active/ folder, which is not necessarily the folder containing the mail merge main document. To use VBA to fix the path, you really have to do at least two things: c. make sure that the Mail Merge Main Document is never saved with any data source information - otherwise, when you re-open it, the first thing that Word does is to try to locate the existing data source. You can't write a macro that intercepts Word before this point and you can't really guarantee to avoid the dialog boxes that will appear if the data source is not found. d. use an AutoOpen macro to connect to the new data source To disconnect a datasource from its datasource before saving it, you can use ActiveDocument.MailMerge.MainDocumentType = wdNotAMergeDocument You will lose the source name, connection information and any sort/filter selections, but not any of the fields in the document. Here's a sample AutoOpen for you: 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 When connecting programmatically, you may also have to implement the registry change described in http://support.microsoft.com/kb/825765 Peter Jamieson "Blackshadow" wrote in message ... How do I connect to a mail merge data base using a relative path? |
Reply |
Thread Tools | |
Display Modes | |
|
|
Similar Threads | ||||
Thread | Forum | |||
Relative Path to a mail merge | Mailmerge | |||
Mail merge with relative path | Mailmerge | |||
Can't print a mail merge data base doc | Mailmerge | |||
Mail merge is using the wrong data base. Help. | Mailmerge | |||
In mail-merge I can not get the data base to change | Mailmerge |