Results 1 to 3 of 3
  1. #1
    5 Star Lounger
    Join Date
    Jul 2001
    Location
    NJ, USA
    Posts
    617
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Opening a Word document (Access XP)

    I have gotten a command button to open Word and make it active. I am trying to get it to open a specific document. I have used the following code without errors and get Word to be activated, but not the document. Any and all help would/is appreciated. Thank you.

    Private Sub cmdProcedureManaul_Click()
    On Error GoTo Err_cmdProcedureManaul_Click

    Dim oApp As Object

    Set oApp = CreateObject("Word.Application")
    oApp.Visible = True
    Set objDocument = GetObject("c:BillingSOGGDA Management Manual.doc")

    Exit_cmdProcedureManaul_Click:
    Exit Sub

    Err_cmdProcedureManaul_Click:
    MsgBox Err.Description
    Resume Exit_cmdProcedureManaul_Click

    End Sub

    Fay

  2. #2
    Bronze Lounger
    Join Date
    Nov 2001
    Location
    Arlington, Virginia, USA
    Posts
    1,394
    Thanks
    0
    Thanked 3 Times in 3 Posts

    Re: Opening a Word document (Access XP)

    This is a real simple example w/o error handling, etc, using Word Documents collection Open method:

    Public Sub OpenWordDoc(strFilePath As String)

    Dim appWord As Word.Application
    Dim doc As Word.Document
    Set appWord = New Word.Application
    Set doc = appWord.Documents.Open(strFilePath)
    appWord.Visible = True
    appWord.Activate
    Set appWord = Nothing
    Set doc = Nothing

    End Sub

    I never have much luck with GetObject & CreateObject - so I normally create a new instance of Word, then open doc or add template (Add method), etc.

    HTH

  3. #3
    5 Star Lounger
    Join Date
    Jul 2001
    Location
    NJ, USA
    Posts
    617
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Opening a Word document --Follow up thank you

    Mark I wanted to thank you. It took me awhile but I got this into my application and actually got it to work. Thanks for the help. Fay

Posting Permissions

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