PDA

View Full Version : Solved: Need code to open a WORD document for read only.



marshallgrad
12-30-2007, 11:30 PM
Hey gang,
I think what I want to do is simple but being a relative newbie, I haven't been successful in doing it myself.

I have made a FORM and the FORM has a MULTIPAGE on it. On my MULTIPAGE(s) I have listed different department with their phone numbers, thus creating a little roladex of sorts. I want to include on one of my pages a COMMAND BUTTON that would open up a WORD document for READ ONLY. Can someone show me the code to perform this relatively simple task that I seem to be having such a hard time with.

Thanks in advance for any help.
Butch

Bob Phillips
12-31-2007, 04:39 AM
Sub OpenWord()
Dim WordApp As Object
Dim WordDoc As Object

Set WordApp = CreateObject("Word.Application")
Set WordDoc = WordApp.Documents.Open(Filename:="C:\test\test.doc", ReadOnly:=True)
WordApp.Visible = True

'do your stuff

Set WordDoc = Nothing
Set WordApp = Nothing
End Sub

marshallgrad
01-01-2008, 10:47 PM
XLD,
It works beautifully. Thanks so much for the help.

Butch :friends: