CoffeeGuru
Registered User.
- Local time
- Today, 06:51
- Joined
- Jun 20, 2013
- Messages
- 121
Hi
I have a word document that has been set up to pull in a mail merge from Access 2010, this has worked fine for a couple of months now.
I now need to get Access to open the word document for me, But all my attempts all fail.
When the word doc opens this way it does not include the SQL warning link, and the merge does not work, I have no idea why.
As part of this VBA/Macro I also need run 2 further queries qryAAA then qryBBB which can be run at any time before, during or after the word document is opened.
I know there are lots of ways of mail merging Access to Word but I have not understood any of them, so I am hoping I can get this to work.
my non working code:
I have a word document that has been set up to pull in a mail merge from Access 2010, this has worked fine for a couple of months now.
I now need to get Access to open the word document for me, But all my attempts all fail.
When the word doc opens this way it does not include the SQL warning link, and the merge does not work, I have no idea why.
As part of this VBA/Macro I also need run 2 further queries qryAAA then qryBBB which can be run at any time before, during or after the word document is opened.
I know there are lots of ways of mail merging Access to Word but I have not understood any of them, so I am hoping I can get this to work.
my non working code:
Code:
Private Sub Command493_Click()
Dim LWordDoc As String
Dim oApp As Object
'Path to the word document
LWordDoc = "C:\Desktop\DATABASE TEST\Invoice.docx"
If Dir(LWordDoc) = "" Then
MsgBox "Document not found."
Else
'Create an instance of MS Word
Set oApp = CreateObject(Class:="Word.Application")
oApp.Visible = True
'Open the Document
oApp.Documents.Open FileName:=LWordDoc
End If
End Sub
Last edited: