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

Posting Rules

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

Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
Word 2000 mail merge documents won't save Access 2000 data source Andy C Mailmerge 1 May 17th 06 08:39 AM
Editing Mail Merge Recipients Stan W. Mailmerge 8 May 4th 06 05:03 AM
Using HTML file as data source for Mail Merge thenin Mailmerge 4 November 21st 05 08:03 AM
word cannot open file as a data or header source bec it is a mail merge main doc gerry Mailmerge 1 November 20th 05 01:24 PM
DotNet Data Table as Mail Merge Data Source goraya Mailmerge 1 July 7th 05 09:51 AM


All times are GMT +1. The time now is 03:13 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"