Microsoft Office Tutorials and References
In Depth Information
Mail Merge: Using a Relative Path for Data Source
'Otherwise, display the dialog box¶
'so that the user can select the data file¶
End If¶
'Turn the warnings back on¶
Application.DisplayAlerts = wdAlertsAll¶
End Sub¶
' * * * * *¶
Sub AutoClose()¶
'Unlink the data soruce for versions earlier¶
'than 2002 so that no prompt about being unable¶
'to find the data source appears when opening¶
If Application.Version < 10 Then¶
ActiveDocument.MailMerge.MainDocumentType _¶
= wdNotAMergeDocument¶
End If¶
'Save this change. Note that any other changes¶
'will also be saved! If choosing whether¶
'or not to save changes is desired,¶
'comment the next line out¶
End Sub¶
' * * * * *¶
Sub AutoOpen()¶
End Sub¶
Follow these steps:
1. Add a module to the mail merge main document or to the template from
which the merge documents will be created. These are the files that will
be dynamically linked to the data source.
2. Copy the LinkToDataSource and AutoOpen procedures into a standard
3. Change the file name for the CONST value to the file name of the data
source. Alter the 'OpenDataSource' method in the 'LinkToDataSource'
procedure so that it can link to the data source (see more below).
The macro runs automatically when the document is opened.
If you are using a Word document as the data source, there won't be a need to
change anything in the 'OpenDataSource' method. For all other types of data
sources, record a macro while you link to the data source. Copy the
'OpenDataSource' lines from the code generated by the macro recorder and use
it to replace the 'OpenDataSource' lines in the sample code. Then substitute the
Path variable everywhere a full file path exists in the recorded code.
Search JabSto ::

Custom Search