Opening a Word Document from Access Form

G

Glenn

The following is the code that I am using to open a Word
Document from an Access Form.

It Works fine until the document is showing in Word - The
following pop-up keeps showing up:

Object doesn't support this property or method.

What am I including in my code that shouldn't be there???

Thanx for the help...

Private Sub cmdAssetNumbering_Click()
On Error GoTo Err_cmdAssetNumbering_Click

Dim oApp As Object
Dim strDocOpenPathName As String

strDocOpenPathName = "s:\stores assets\Asset Numbering
Convention.doc"

Set oApp = CreateObject("Word.Application")
Set oApp = oApp.Documents.Open(strDocOpenPathName, , ,
True)

oApp.Visible = True

oApp.Application.Quit
Set oApp = Nothing

Exit_cmdAssetNumbering_Click:
Exit Sub

Err_cmdAssetNumbering_Click:
MsgBox Err.Description
Resume Exit_cmdAssetNumbering_Click

End Sub
 
M

Mark Phillipson

Glen,

I have revised your code so it will now work:

On Error GoTo Err_cmdAssetNumbering_Click

Dim oApp As Object
Dim strDocOpenPathName As String

strDocOpenPathName = "s:\stores assets\Asset Numbering Convention.doc"
Set oApp = CreateObject("Word.Application")
With oApp
.Documents.Open strDocOpenPathName, , , True
.Visible = True
'oApp.Quit
End With
Set oApp = Nothing

Exit_cmdAssetNumbering_Click:
Exit Sub

Err_cmdAssetNumbering_Click:
MsgBox Err.Description
Resume Exit_cmdAssetNumbering_Click

I have remarked out the Quit as there seems to be no point in quitting.

HTH

--

Cheers
Mark

Free Access/Office Add-Ins at:
http://mphillipson.users.btopenworld.com/
 

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