troubleshooting Question

From Access use VB to Check if Outlook 2010 open in 64 bit environment - if not open it

Avatar of Scamquist
ScamquistFlag for United States of America asked on
Microsoft AccessVB Script
3 Comments1 Solution546 ViewsLast Modified:
I have code I used to check if Outlook is open. If not, it would open it.  I am now using a 64 bit computer and the code no longer works.  I changed the declare statements.  I now get a compile error. Type mismatch on the FIndWindow statement.  Any ideas?  The code is below.  I commented out my original Declare statements:
______________________________________________________________________________________

'Private Declare Function FindWindow Lib "User32" Alias "FindWindowA" (ByVal lpClassName As String, ByVal lpWindowName As String) As Long
Private Declare PtrSafe Function FindWindow Lib "USER32" Alias "FindWindowA" (ByVal lpClassName As String, ByVal lpWindowName As String) As LongPtr
'Private Declare Function SetForegroundWindow Lib "User32" (ByVal hWnd As Long) As Long
Private Declare PtrSafe Function SetForegroundWindow Lib "USER32" (ByVal hWnd As LongPtr) As LongPtr


Public Function IsOutlookOpen() As Boolean
On Error GoTo IsOutlookOpen_Err
Dim gobjOutlook As Object
Dim lngWindow As Long

lngWindow = FindWindow(vbNullString, "Microsoft Outlook")

If lngWindow <> 0 Then
  IsOutlookOpen = True
  Exit Function
End If
Shell "C:\Program Files\Microsoft Office\Office14\OUTLOOK.EXE"


Exit Function

IsOutlookOpen_Exit:
  Exit Function
 
IsOutlookOpen_Err:
  Select Case Err
 
  Case 429
    IsOutlookOpen = False
    Exit Function
  End Select

End Function
Join the community to see this answer!
Join our exclusive community to see this answer & millions of others.
Unlock 1 Answer and 3 Comments.
Join the Community
Learn from the best

Network and collaborate with thousands of CTOs, CISOs, and IT Pros rooting for you and your success.

Andrew Hancock - VMware vExpert
See if this solution works for you by signing up for a 7 day free trial.
Unlock 1 Answer and 3 Comments.
Try for 7 days

”The time we save is the biggest benefit of E-E to our team. What could take multiple guys 2 hours or more each to find is accessed in around 15 minutes on Experts Exchange.

-Mike Kapnisakis, Warner Bros