Consulting

Results 1 to 3 of 3

Thread: Solved: Need code to open a WORD document for read only.

  1. #1
    VBAX Regular
    Joined
    Dec 2006
    Location
    Kentucky
    Posts
    19
    Location

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

    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

  2. #2
    Distinguished Lord of VBAX VBAX Grand Master Bob Phillips's Avatar
    Joined
    Apr 2005
    Posts
    25,443
    Location
    [vba]

    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
    [/vba]
    ____________________________________________
    Nihil simul inventum est et perfectum

    Abusus non tollit usum

    Last night I dreamed of a small consolation enjoyed only by the blind: Nobody knows the trouble I've not seen!
    James Thurber

  3. #3
    VBAX Regular
    Joined
    Dec 2006
    Location
    Kentucky
    Posts
    19
    Location

    Smile

    XLD,
    It works beautifully. Thanks so much for the help.

    Butch

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •