C
Colin Coleman
Hi ,
I have everything in place from the access database side, i can select a
record, create a query in VB "ContractSelect" that contains one record that
i want Word 2003 to display as its datasource when it prints, but what
happens is that when ever i open/launch word from WITHIN Access 2003 it
always shows the last record data from the previous time i ran the program.
BUT if i start Word manually it says connect to SQL...blah and works
correctly.
The access datbase is called Contracts.mdb
The Query in the datbase is called ContractSelect
strDocName Contains the full path and filename for the word mailmerge doc
The code in Access to open word i have created is this:-
Sub OpenWordDoc(strDocName As String)
Dim objApp As Object
' Opens the document
Set objApp = CreateObject("Word.Application")
objApp.Visible = True
objApp.Documents.Open strDocName
' This next bit maybe complete crap....but i cant find any help on doing it
......
objApp.Documents(1).MailMerge.opendataSource _
Name:="C:\data\contracts.mdb", LinkToSource:=True _
, Connection:="QUERIES ContractSelect", SQLStatement:="SELECT * FROM
ContractSelect;"
' Execute the mail merge.
objApp.Documents(1).MailMerge.Execute
End Sub
using the above It opens the document but now comes up with the "data link
Properties box" Then the "Confirm data Source" dialog where I select MS
Access Datbases via DDE (*.mdb,*.mde), then i get an error saying "Word was
unable to open the data source."
Id very much appreciate it someone could help me with this begginers
question.
Thanks
Colin
I have everything in place from the access database side, i can select a
record, create a query in VB "ContractSelect" that contains one record that
i want Word 2003 to display as its datasource when it prints, but what
happens is that when ever i open/launch word from WITHIN Access 2003 it
always shows the last record data from the previous time i ran the program.
BUT if i start Word manually it says connect to SQL...blah and works
correctly.
The access datbase is called Contracts.mdb
The Query in the datbase is called ContractSelect
strDocName Contains the full path and filename for the word mailmerge doc
The code in Access to open word i have created is this:-
Sub OpenWordDoc(strDocName As String)
Dim objApp As Object
' Opens the document
Set objApp = CreateObject("Word.Application")
objApp.Visible = True
objApp.Documents.Open strDocName
' This next bit maybe complete crap....but i cant find any help on doing it
......
objApp.Documents(1).MailMerge.opendataSource _
Name:="C:\data\contracts.mdb", LinkToSource:=True _
, Connection:="QUERIES ContractSelect", SQLStatement:="SELECT * FROM
ContractSelect;"
' Execute the mail merge.
objApp.Documents(1).MailMerge.Execute
End Sub
using the above It opens the document but now comes up with the "data link
Properties box" Then the "Confirm data Source" dialog where I select MS
Access Datbases via DDE (*.mdb,*.mde), then i get an error saying "Word was
unable to open the data source."
Id very much appreciate it someone could help me with this begginers
question.
Thanks
Colin