Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Microsoft Word ?

Status
Not open for further replies.

cj92713696

Programmer
Nov 23, 2000
105
US
How does one determine if a Word document is currently running? I want to write a program that appends a document to Word if it is running or in the event it is not running, open Word and add a document.

Thanks,
CJ
 
Here you go!
Code:
Sub StartWord()
    Dim wdApp As Word.Application
    On Error Resume Next
    Set wdApp = GetObject(, "Word.Application")
    If Err.Number <> 0 Then     'Not Running - Start New
        Set wdApp = CreateObject(&quot;Word.Application&quot;)
        Err.Clear
    End If
    On Error GoTo 0
    wdApp.Visible = True
    wdApp.WindowState = wdWindowStateMaximize
    wdApp.Documents.Add
End Sub
 
Thanks a lot!

That worked great! I really appreciate it!

CJ
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top