Opening a Word Document from Access

G

Guest

I am trying to Open a Word Document from an Access form "User Documentation"
I get an Automation Error. I am using Access 2000 for testing. However, it
will be installed using Access 97. Could some one please help:

Private Sub Command0_Click()

Dim objword As Word.Application
Dim objDoc As Word.Document
Dim DocPath As String

DocPath = "c:\MyPath\UserDoc.doc"

Set objword = New Word.Application

'************************************************
' Automation Error - The Server Threw An Exception
' Run Time Error -2147417851
' Note - I have Triple Check the Path, It's Correct
'************************************************
Set objDoc = objword.Documents.Open(DocPath)
'************************************************

objDoc.Activate
objword.Visible = True

End Sub
 
G

Guest

Do you have reference to Microsoft Word 11.0 Object Library?
To check open any code section, or the immidiate window, select tools,
reference.
If you dont have then create by browsing and selecting MSWORD.OLB, probably
under c:\Program Files\Microsoft Office\Office11\

But its better to check by searching for it.
 
G

Graham Mandeno

If you want it to work with multiple versions, you must use late binding.
Remove the reference to the Word object library and change your code as
follows:
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top