Results 1 to 2 of 2
  1. #1
    3 Star Lounger
    Join Date
    Jan 2001
    Location
    Canada
    Posts
    284
    Thanks
    0
    Thanked 0 Times in 0 Posts

    How would I open a corresponding Word document (Access 2000)

    I have a form that has a button on it that opens Word. But I want it to open a certain document in Word depending on what record I am in. For example, I go into record 1 and the form has a button to open a file called "Problem1.doc". If I go into record 2 and click the button it should bring up file "Problem2.doc". So the button opens up the document with the corresponding number.

    The field name for the record number is [ProblemNum]. The files are all called "Problem[ProblemNum].doc". Is this possible to do? Here's the code for my button so far.

    Private Sub cmdDetail_Click()
    On Error GoTo Err_cmdDetail_Click

    Dim oApp As Object

    Set oApp = CreateObject("Word.Application")
    oApp.Visible = True

    Exit_cmdDetail_Click:
    Exit Sub

    Err_cmdDetail_Click:
    MsgBox Err.Description
    Resume Exit_cmdDetail_Click

    End Sub

  2. #2
    Plutonium Lounger
    Join Date
    Mar 2002
    Posts
    84,353
    Thanks
    0
    Thanked 29 Times in 29 Posts

    Re: How would I open a corresponding Word document (Access 2000)

    You don't need to create a Word.Application object. Try this:

    Private Sub cmdDetail_Click()
    On Error GoTo Err_cmdDetail_Click
    ' Substitute the appropriate path
    Application.FollowHyperlink "CocumentFolderProblem" & Me.[ProblemNum] & ".doc"

    Exit_cmdDetail_Click:
    Exit Sub

    Err_cmdDetail_Click:
    MsgBox Err.Description
    Resume Exit_cmdDetail_Click
    End Sub

Posting Permissions

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