+ Reply to Thread
Results 1 to 4 of 4

Open MS WORD document from Excel macro?

Hybrid View

  1. #1
    Forum Contributor Rick_Stanich's Avatar
    Join Date
    11-21-2005
    Location
    Ladson SC
    MS-Off Ver
    Office365
    Posts
    1,177

    Open MS WORD document from Excel macro?

    I can't seem to figure this one out.
    I have a Toolbar button with a hyperlink to a MS WORD document, I would like to make it a Macro.
    Regards

    Rick
    Win10, Office 365

  2. #2
    Forum Contributor
    Join Date
    08-14-2006
    Location
    USA
    MS-Off Ver
    2019
    Posts
    686
    This will open the file whether Word is already open or not
    and give it focus

    Sub StartWordFile()
    
    Dim docWord As Object
    Set docWord = CreateObject("Word.Application")
    docWord.Visible = True
    docWord.Documents.Open Filename:="C:\Documents and Settings\....full path here.....doc"
    
    End Sub

  3. #3
    Forum Expert dominicb's Avatar
    Join Date
    01-25-2005
    Location
    Lancashire, England
    MS-Off Ver
    MS Office 2000, 2003, 2007 & 2016 365
    Posts
    4,867

    Smile

    Good afternoon Rick_Stanich

    There are a number of ways to do this but this is my favourite. Basically, it will open any file using the default Windows viewer.

    Private Declare Function ShellExecute Lib "shell32.dll" Alias "ShellExecuteA"  (ByVal hWnd As Long, ByVal lpOperation As String, ByVal lpFile As String, ByVal lpParameters As String, ByVal lpDirectory As String, ByVal nShowCmd As Long) As Long
    Sub test()
    On Error Resume Next
    ShellExecute 0&, vbNullString, "D:\Work\MyFile.doc", vbNullString, vbNullString, vbNormalFocus
    End Sub
    HTH

    DominicB
    Please familiarise yourself with the rules before posting. You can find them here.

  4. #4
    Forum Contributor Rick_Stanich's Avatar
    Join Date
    11-21-2005
    Location
    Ladson SC
    MS-Off Ver
    Office365
    Posts
    1,177
    Thank you!!!

    This has helped alot!

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Bookmarks

Posting Permissions

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

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1