Are you calling OpenDataSource in your Access code? If not, it would
probably be a good idea to do so, but you will need to remove any existing
connection from the Word mail merge main document because Word will try to
open the existing connection before any OpenDataSource method call can
execute (whether it is in Access or Word). Removing the existing connection
will lose any sort/filter options but all the field codes etc. remain
intact.
If so, you need to use something along the following lines:
Dim sConnaection As String
Dim sName As String
Dim sSQL As String
sName:="the full path name of your Access database"
sConnection="TABLE tablename"
' or
' sConnection = "QUERY queryname"
' If you need to sort or filter the data, use ORDER BY
' and/or WHERE clauses in here
sSQL = "SELECT * FROM [table or query name]"
oWordDocumentObject.OpenDataSource _
Name:=sName, _
Connection::=sConnection, _
SQLStatement:=sSQL, _
Subtype:=wdMergeSubtypeWord2000
NB if you don't add a reference to the Word object library in the Access VBA
editor, you will need to use
Subtype:=8
Peter Jamieson
> The mail merge is being called from the Access database via a Visual Basic
> function. The message that comes up is:
[quoted text clipped - 54 lines]
>> >> > but this didn't have any effect. Any suggestions???
>> >> > Thanks.
mvb - 06 Sep 2005 17:11 GMT
Peter ;
Thanks for your help!
Due to holidays the issue wasn't reviwed until this week.
Adding "Subtype:=wdMergeSubtypeWord2000" worked in suppressing the linking
dialog box.
However...I am now receiving the message: "Opening this document will run
the following SQL command: Select from querynnn. Data from your database
will be placed in the document. Do you want to continue?" on some, but not
all, of the mail merge routines.
Any further suggestions?
Thanks again
Marc
> Are you calling OpenDataSource in your Access code? If not, it would
> probably be a good idea to do so, but you will need to remove any existing
[quoted text clipped - 91 lines]
> >> >> > but this didn't have any effect. Any suggestions???
> >> >> > Thanks.