Open Word

S

SF

Hi,

I have the following code to open a word document. It appear that the code
below open word document but I do not see it (may be in hidden mode?). Could
someone help?

Public Function OpenWordDoc(DocPath As String)
On Error GoTo Exit_OpenWordDoc

Dim WordObj As Object
Set WordObj = CreateObject("Word.Application")
WordObj.Visible = True
WordObj.Documents.Open DocPath ''"C:\Wordtest.doc"
Set WordObj = Nothing

Exit_OpenWordDoc:
DoCmd.Hourglass False
Exit Function
Err_OpenWordDoc:
MsgBox Err.Number, vbOKOnly + vbInformation
Resume Exit_OpenWordDoc:
End Function


SF
 
A

Arvin Meyer MVP

Works fine for me. I did move the Set WordObj = Nothing to the exit
procedure to ensure it will always fire.
 
K

kate

SF said:
Hi,

I have the following code to open a word document. It appear that the code
below open word document but I do not see it (may be in hidden mode?).
Could someone help?

Public Function OpenWordDoc(DocPath As String)
On Error GoTo Exit_OpenWordDoc

Dim WordObj As Object
Set WordObj = CreateObject("Word.Application")
WordObj.Visible = True
WordObj.Documents.Open DocPath ''"C:\Wordtest.doc"
Set WordObj = Nothing

Exit_OpenWordDoc:
DoCmd.Hourglass False
Exit Function
Err_OpenWordDoc:
MsgBox Err.Number, vbOKOnly + vbInformation
Resume Exit_OpenWordDoc:
End Function


SF
 

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