Results 1 to 3 of 3
  1. #1
    Join Date
    May 2005
    Posts
    119

    Unanswered: Outlook already Opened?

    Does anyone know how to tell if Outlook is already opened? I have a procedure that send e-mail automatically and want to put in {if Outlook is not opened, open it} code.

    Also, (maybe I'll post this one separately) does anyone know how to access the GAL (global address book) via a form in Access to populate fields?

    TIA,
    Krista

  2. #2
    Join Date
    Feb 2004
    Location
    One Flump in One Place
    Posts
    14,912
    The easiest way to check if outlook is open is use GetObject and handle the error if it isn't. Remember to omit the Path arguement!

    HTH
    Testimonial:
    pootle flump
    ur codings are working excelent.

  3. #3
    Join Date
    Dec 2005
    Location
    Texas
    Posts
    100
    I got this for Excel, should work the same way with Outlook though you'll obviously have to tweak it; mostly it came from O'Reilly's Access Cookbook:

    Code:
    Declare Function acb_apiFindWindow Lib "user32" Alias "FindWindowA" (ByVal strClassName As String, ByVal lpWindowName As Any) As Long
    
    Function acbIsAppLoaded(ByVal varClassName As Variant) As Long
        ' Report if an application is currently loaded
        ' In:
        '     strClassName: the Windows class name for the main window
        '                   of the app to check for.
        ' Out:
        '     Return Value: 0 if App isn't loaded, non-zero (the
        '         app's hWnd) otherwise.
    
       If IsNull(varClassName) Then
          acbIsAppLoaded = 0
       Else
          acbIsAppLoaded = acb_apiFindWindow(CStr(varClassName), 0&)
       End If
    End Function
    
    
    Function IsExcelRunning()
    
    Dim hWnd As Variant
    Dim blflag As Boolean
    
    hWnd = acbIsAppLoaded("XLMain")
    
    'MsgBox hWnd
    
    If hWnd <> 0 Then
    blflag = True
    ElseIf hWnd = 0 Then
    blflag = False
    End If
    
    
    IsExcelRunning = blflag
    
    End Function
    And here's how I call it:

    Code:
    If IsExcelRunning = False Then
        Set xlApp = New Excel.Application
    Else
        Set xlApp = GetObject(, "Excel.Application")
    End If
    Here's a URL with Microsoft Office window class names.

    http://users.skynet.be/am044448/Prog...lass_names.htm

    Hope this helps!

Posting Permissions

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