Opening a Word.doc

S

steve

Any good code to simply open a Word.doc from within
Access without using a hyperlink?

Thanks,
Steve
 
G

Graham Mandeno

Hi Steve

How about this? It uses late binding so you won't need any references to
the Word object library.

Public Sub OpenWordDocument(sDocFile As String, _
Optional fReadOnly As Boolean)
Dim oWordApp As Object
Dim oDoc As Object
On Error GoTo ProcErr
Set oWordApp = CreateObject("Word.Application")
Set oDoc = oWordApp.Documents.Open(sDocFile, ReadOnly:=fReadOnly)
oWordApp.Visible = True
ProcEnd:
Set oDoc = Nothing
Set oWordApp = Nothing
Exit Sub
ProcErr:
MsgBox "Cannot open " & sDocFile & VbCrLf & Err.Description
Resume ProcEnd
End Sub
 

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