opening a word document from Access

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:
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:
You don't have to have the
Class:=
BUT, the app must have a reference to Word, in VBE.
Press Ctl-G
In the VBE menu, Tools, References,
In the list make sure it has Word check marked.
And it doesn't say MISSING.
 
OK So I added in the Microsoft Word 14.0bject Library
Saved and closed and reopened my database but I still get the same problem
No merged documents.. :confused:
 
you may need to activate the merge.
(in addition of just opening the doc)
 

Users who are viewing this thread

Back
Top Bottom