• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 857
  • Last Modified:

Excel VBA open word file

  Does anyone have a good VBA example to perform the following...

Using Excel VBA...
Open the file specified below using CommandButton2.

What I have so far...

Private Sub CommandButton2_Click()

    file to be opened -
        \\usdata024\RC_Utilities\RED Compass Utilities\DRA Tool_Whats New.docx

End Sub
1 Solution
Sub HandlingWord()
    Dim mwApp As Object, pathname as string

    pathname = "\\usdata024\RC_Utilities\RED Compass Utilities\DRA Tool_Whats New.docx"

    On Error Resume Next
    Set mwApp = CreateObject("Word.Application")

    If mwApp Is Nothing Then
        Set mwApp = CreateObject("Word.Applcation")
        If mwApp Is Nothing Then
            MsgBox "Word is not accessable!", vbExclamation
            Exit Sub
        End If
    End If

    mwApp.Visible = True

    mwApp.Documents.Open pathname
    e = Err.Number
    On Error GoTo 0

End Sub

Open in new window

Try that
tesla764Author Commented:
That works Great. Thank You very much.
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

Join & Write a Comment

Featured Post

Free Tool: ZipGrep

ZipGrep is a utility that can list and search zip (.war, .ear, .jar, etc) archives for text patterns, without the need to extract the archive's contents.

One of a set of tools we're offering as a way to say thank you for being a part of the community.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now