Reply
 
Thread Tools Display Modes
  #1   Report Post  
Posted to microsoft.public.word.mailmerge.fields
Blackshadow Blackshadow is offline
external usenet poster
 
Posts: 1
Default 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   Report Post  
Posted to microsoft.public.word.mailmerge.fields
Peter Jamieson Peter Jamieson is offline
external usenet poster
 
Posts: 4,582
Default 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

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
Relative Path to a mail merge Anderflash Mailmerge 1 January 14th 07 12:09 AM
Mail merge with relative path Anderflash Mailmerge 5 January 10th 07 02:57 PM
Can't print a mail merge data base doc ohiomasons Mailmerge 1 April 30th 05 10:50 PM
Mail merge is using the wrong data base. Help. diamond4law Mailmerge 1 February 15th 05 11:21 PM
In mail-merge I can not get the data base to change Cannuck3 Mailmerge 1 December 11th 04 12:16 AM


All times are GMT +1. The time now is 12:59 AM.

Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 Microsoft Office Word Forum - WordBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Word"