is there a way
to change this data source to relative path??
Not easily - you have to use code, e.g. Word VBA.
First, before you distribute the solution, ensure that the Mail Merge Main
Document has been disconnected from its data source. You have to do that
because nothing you do in VBA can change the data source path /before/ Word
tries to open it.
You can disconnect the data source while the mail merge main document is
open by using
ActiveDocument.MailMerge.MainDocumentType = wdNotAMergeDocument
in the Word VBA Editor Immediate WIndow.
Then, in Word VBA, create an ordinary module in your Document and put a
routine such as the following in it - this assumes that you know the name of
the .xls and that it will be in the same folder as the .doc
Sub AutoOpen()
Dim strDataSource As String
Dim strConnection As String
Dim strQuery As String
' set this to be the file name of your data source
strDataSource = "myexcelfile.xls"
' set this to be the connection string for your data source
'strConnection = ""
' set this to be the query for your data source
' if you need to sort aor filter, you need to add
' the appropriate ORDER BY and WHERE clauses
' strQuery = "SELECT * FROM [myrangename]"
With ActiveDocument
strDataSource = .Path & "\" & strDataSource
With .MailMerge
.OpenDataSource _
Name:=strDataSource, _
SQLStatement:=str
' 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
Unfortunately, you, or your user, will probably also have to take account of
the following artiicle:
http://support.microsoft.com/kb/825765/en-us
--
Peter Jamieson
http://tips.pjmsn.me.uk
SHKDXB said:
hi anybody can help me to make the path of the data source as relative?.
when
trnasporting the files to other machines, i have problem of missisng data
soure - due to absoulte path in the main mail merge documnet. is there a
way
to change this data source to relative path??