+ Reply to Thread
Results 1 to 4 of 4

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 and doesn't wait for Word to close. Anybody have some code that works for this?

    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 FileName 
    As String
        Dim Result 
    As Long        
        
    If Right(Path1) <> "\" Then _
            Path = Path & "
    \"
            
        FileName = Path & File_Name
        Result = ShellExecute(0&, vbNullString, FileName, _
            vbNullString, vbNullString, vbNormalFocus)
        If Result < 32 Then MsgBox "
    Error"
        
    End Sub ' Shell_Execute 
    Thanks for any help. - Mac

  2. #2
    Valued Forum Contributor spitfireblue's Avatar
    Join Date
    01-29-2015
    Location
    Adelaide, Australia
    MS-Off Ver
    2007,2010,2016
    Posts
    611

    Re: How to open Word from VBA?

    Have you tried something like this?

    Please Login or Register  to view this content.

  3. #3
    Forum Expert macropod's Avatar
    Join Date
    12-22-2011
    Location
    Canberra, Australia
    MS-Off Ver
    Word, Excel & Powerpoint 2003 & 2010
    Posts
    3,726

    Re: How to open Word from VBA?

    There is plenty of fully-working code around. For example: http://www.excelforum.com/word-progr...ml#post4114924
    Cheers,
    Paul Edstein
    [Fmr MS MVP - Word]

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

    Re: How to open Word from VBA?

    Thanks one and all for the help.

    The problem turned out to be trivial: I had the name of the program name with 3 "T"'s in it rather than 2. And my error checking software was catching it but I wasn't smart enough to figure that out until now.

    Mac

+ Reply to 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