Closed Thread
Results 1 to 2 of 2

How to open Word from VBA?

  1. #1
    Forum Contributor
    Join Date
    10-02-2008
    Location
    Berkeley, CA
    MS-Off Ver
    Windows 2007
    Posts
    105

    How to open Word from VBA?

    I've tried a number of methods found on the internet, but all seem to cause an error.

    I need have a macro that opens an existing file in Word. Anybody have some code that works for them.

    Here's one example of what I've found:

    PHP Code: 
    Private Declare Function ShellExecute Lib "shell32.dll" _
      Alias 
    "ShellExecuteA" (ByVal hWnd As Long_
      ByVal lpOperation 
    As StringByVal lpFile As String_
      ByVal lpParameters 
    As StringByVal lpDirectory As String_
      ByVal nShowCmd 
    As Long) As Long

    Sub Shell_Execute
    (PathFile_Name)
        
    ' From John Wallenbeck
        ' 
    1/19/16 WML
        
        Dim objWord
        Dim objDoc
        Dim Result 
    As Long
        
        Prog 
    "Shell_Execute"
        
        
    If Right(Path1) <> "\" Then _
            Path = Path & "
    \"
            
        FileName = Path & File_Name
        Rt_F_N = Right(FileName, 60)

        Set objWord = CreateObject("
    Word.Application")
        Set objDoc = objWord.Documents.Open(FileName)
        objWord.Visible = True
        
    End Sub ' Shell_Execute 
    Thanks for any help. - Mac

  2. #2
    Administrator FDibbins's Avatar
    Join Date
    12-29-2011
    Location
    Duncansville, PA USA
    MS-Off Ver
    Excel 7/10/13/16/365 (PC ver 2310)
    Posts
    52,917

    Re: How to open Word from VBA?

    This is a duplicate post - as notified by the OP. I will close this now
    1. Use code tags for VBA. [code] Your Code [/code] (or use the # button)
    2. If your question is resolved, mark it SOLVED using the thread tools
    3. Click on the star if you think someone helped you

    Regards
    Ford

Closed Thread

Thread Information

Users Browsing this Thread

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

Similar Threads

  1. Open Word docm from Excel: Test if already open? Word errors?
    By brucemc777 in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 02-21-2014, 01:02 PM
  2. Word browsing folder and open txt files in word document.
    By naseerrahaman in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 02-16-2013, 03:38 AM
  3. Check if a Word File is Open and If Open Close it with Excel VBA.
    By e4excel in forum Excel Programming / VBA / Macros
    Replies: 5
    Last Post: 12-10-2012, 11:14 AM
  4. Word tries to open individual file for every word in the name
    By gjjh25 in forum Word Formatting & General
    Replies: 20
    Last Post: 09-08-2011, 07:40 AM
  5. Macro to open word doc, then open another file in word and then excute a find replace
    By Uber-Smee in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 07-29-2010, 09:43 AM
  6. How to open a Word.doc using VBA and count the words in the word.doc?
    By eijoah in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 11-05-2007, 12:58 AM
  7. Replies: 2
    Last Post: 10-13-2006, 08:41 AM
  8. Replies: 4
    Last Post: 10-09-2006, 10:03 AM

Tags for this Thread

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