Results 1 to 4 of 4
  1. #1
    New Lounger
    Join Date
    Mar 2003
    Location
    Little Silver, New Jersey, USA
    Posts
    2
    Thanks
    0
    Thanked 0 Times in 0 Posts

    New Word Object (Word 2000/02)

    Trying to find a good routine to test and see if Word is running prior to having a routine fireup in VB. The few I have been able to find on the MS site don't seem to fit the bill.

    Any help would be greatly appreciated.

  2. #2
    Plutonium Lounger
    Join Date
    Mar 2002
    Posts
    84,353
    Thanks
    0
    Thanked 29 Times in 29 Posts

    Re: New Word Object (Word 2000/02)

    I use code like this; perhaps you can adapt it for your own use. It's easy to adapt for Excel, Outlook, PowerPoint too.

    <img src=/w3timages/blueline.gif width=33% height=2>

    Dim blnNotActive As Boolean
    Dim objWordApp As Word.Application

    ' No error messages here
    On Error Resume Next

    ' Check whether Word is active
    Set objWordApp = GetObject(, "Word.Application")
    blnNotActive = (Err <> 0)
    If blnNotActive Then
    ' If not, we start Word
    Err.Clear
    Set objWordApp = CreateObject("Word.Application")
    End If

    ' Resume standard error handling here
    On Error GoTo Err_Handler ' or GoTo 0 if you don't handle it yourself

    <img src=/w3timages/blueline.gif width=33% height=2>

  3. #3
    Plutonium Lounger
    Join Date
    Nov 2001
    Posts
    10,550
    Thanks
    0
    Thanked 7 Times in 7 Posts

    Re: New Word Object (Word 2000/02)

    Dim objWord As Object

    On Error Resume Next
    Set objWord = GetObject(, "word.application")
    If objWord Is Nothing Then
    MsgBox "Word is NOT running"
    Else
    MsgBox "Word is running"
    End If

    StuartR

    Edited to add
    Hans always beats me to it, but I will leave this example here as it is a little shorter...

  4. #4
    New Lounger
    Join Date
    Mar 2003
    Location
    Little Silver, New Jersey, USA
    Posts
    2
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: New Word Object (Word 2000/02)

    Thanks for the help. Between these two I think I can come up with a solution. Appreciate your time.

Posting Permissions

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