Results 1 to 35 of 35

Thread: [RESOLVED] Outlook being open and detecting it.

  1. #1

    Thread Starter
    Addicted Member
    Join Date
    Jun 2006
    Location
    Texas
    Posts
    162

    Resolved [RESOLVED] Outlook being open and detecting it.

    I am using Outlook to send emails from within our program. I detect Outlook by creating an instance of it:

    Set oApp = CreateObject("Outlook.Application")

    If Outlook is there, no error and if not then error 429. All that works great. Only issue is that if the user already has Outlook running (not just installed but actually running) then it errors out with the 429 too. You close Outlook and works fine. For now, we have just been telling customers not to have it running. However, lately we have been noticing some customers with Outlook running and it NOT getting the error but works fine. How can I get it to detect even with Outlook running? On my personal system, if Outlook is running then it won't detect.

  2. #2
    Enjoy the moment
    Join Date
    Feb 2011
    Location
    Barrio Del pilar madrid spain
    Posts
    5,204

    Re: Outlook being open and detecting it.

    found some sample codes maybe it will help
    Code:
    Sub ActivateOL()
       'Error 429 occurs with GetObject if Outlook is not running.
       On Error Resume Next
       Set objOutlook = GetObject(, "Outlook.Application")
       
       If Err.Number = 429 Then 'Outlook is NOT running.
          MsgBox "Outlook is not running"
       Else
          AppActivate objOutlook.ActiveExplorer.Caption
       End If
    End Sub
    Code:
    Dim olApp As Object
     
    On Error Resume Next
     
    Set olApp = GetObject(,"Outlook.Application")
     
    On Error Goto 0
     
    If Not olApp Is Nothing Then
      'Outlook is open!
    Else
      'Outlook not open
    End if

  3. #3
    Discovering Life Siddharth Rout's Avatar
    Join Date
    Feb 2005
    Location
    Mumbai, India
    Posts
    12,001

    Re: Outlook being open and detecting it.

    See this example

    Code:
    Sub Sample()
        Dim OutApp As Object, OutMail As Object
        
        '~~> Establish an Outlook application object if it is already open
        On Error Resume Next
        Set OutApp = GetObject(, "Outlook.Application")
        
        '~~> If not then, launch it
        If Err.Number <> 0 Then
            Set OutApp = CreateObject("Outlook.Application")
        End If
        Err.Clear
        On Error GoTo 0
        
        '~~> OutApp is nothing that means Outlook is not installed
        If OutApp Is Nothing Then
            MsgBox "Please check if Outlook is installed"
            Exit Sub
        End If
        
        Set OutMail = OutApp.CreateItem(0)
        
        '
        '~~> Rest of the code
        '
    End Sub
    Also are you doing this from VB6 or VBA?
    A good exercise for the Heart is to bend down and help another up...
    Please Mark your Thread "Resolved", if the query is solved


    MyGear:
    ★ CPU ★ Ryzen 5 5800X
    ★ GPU ★ NVIDIA GeForce RTX 3080 TI Founder Edition
    ★ RAM ★ G. Skill Trident Z RGB 32GB 3600MHz
    ★ MB ★ ASUS TUF GAMING X570 (WI-FI) ATX Gaming
    ★ Storage ★ SSD SB-ROCKET-1TB + SEAGATE 2TB Barracuda IHD
    ★ Cooling ★ NOCTUA NH-D15 CHROMAX BLACK 140mm + 10 of Noctua NF-F12 PWM
    ★ PSU ★ ANTEC HCG-1000-EXTREME 1000 Watt 80 Plus Gold Fully Modular PSU
    ★ Case ★ LIAN LI PC-O11 DYNAMIC XL ROG (BLACK) (G99.O11DXL-X)
    ★ Monitor ★ LG Ultragear 27" 240Hz Gaming Monitor
    ★ Keyboard ★ TVS Electronics Gold Keyboard
    ★ Mouse ★ Logitech G502 Hero

  4. #4

    Thread Starter
    Addicted Member
    Join Date
    Jun 2006
    Location
    Texas
    Posts
    162

    Re: Outlook being open and detecting it.

    Using VB6. But as I said, I'm currently using the CreateObject("Outlook.Application") method but have tried to use both. If Outlook is already opened, either method returns the 429 error.

  5. #5
    Frenzied Member
    Join Date
    Mar 2008
    Posts
    1,210

    Re: Outlook being open and detecting it.

    I think we had better see you actual code including the definition of your oApp variable.

  6. #6
    Smooth Moperator techgnome's Avatar
    Join Date
    May 2002
    Posts
    34,532

    Re: Outlook being open and detecting it.

    There is GetObject .. which will attempt to get an instance if the app is running... so if it is, then you know it's installed AND running and can sue the returned instance to do what you need. If it errors out, then it's NOT running, but it is unknown if it is installed and not running or simply not installed... so you then use CreateObject to create an instance... If THAT then fails, then OL isn't installed. If it succeeds, then it IS installed and you now have a reference to it and can use it as you need.

    GetObject should NOT be returning an error if OL is already running... unless the code isn't right... but I've used this technique before against Excel and Word w/o issues, so OL shouldn't be all that different.

    -tg
    * I don't respond to private (PM) requests for help. It's not conducive to the general learning of others.*
    * I also don't respond to friend requests. Save a few bits and don't bother. I'll just end up rejecting anyways.*
    * How to get EFFECTIVE help: The Hitchhiker's Guide to Getting Help at VBF - Removing eels from your hovercraft *
    * How to Use Parameters * Create Disconnected ADO Recordset Clones * Set your VB6 ActiveX Compatibility * Get rid of those pesky VB Line Numbers * I swear I saved my data, where'd it run off to??? *

  7. #7

    Thread Starter
    Addicted Member
    Join Date
    Jun 2006
    Location
    Texas
    Posts
    162

    Re: Outlook being open and detecting it.

    Here is code:

    Code:
    Sub CheckForOutlook()
    
    On Error GoTo ErrorHandling
    
    'Test for Outlook being installed
    
    'First assume it is installed and if gets error 429 when attempt to CreateObject then turn it off
        OutlookIsInstalled = True
    
        Dim oApp As Object
        Set oApp = GetObject(, "Outlook.Application")  'This will only tell you if it is currently running
        Set oApp = CreateObject("Outlook.Application")  'This tells you that it is installed so able to actually create object
            
        If OutlookIsInstalled Then
            'Turn on Status LED
        Else
            'Turn off Status LED
        End If
            
    Exit Sub
    
    ErrorHandling:
            
        'If gets this error then turn Outlook flag off
        If Err = 429 Then
            OutlookIsInstalled = False
            Resume Next
            End If
            
        ErrorHandler "Testing for Outlook", ReturnCode
         
        Resume
    
    End Sub
    
    
    These are in my declarations:
    
    '----For Outlook
    Global objOutlook As New Outlook.Application
    Global objOutlookMsg As Outlook.MailItem
    Last edited by mickeykelley; Oct 10th, 2013 at 01:40 PM.

  8. #8
    Smooth Moperator techgnome's Avatar
    Join Date
    May 2002
    Posts
    34,532

    Re: Outlook being open and detecting it.

    ok... so what's the problem?


    -tg
    * I don't respond to private (PM) requests for help. It's not conducive to the general learning of others.*
    * I also don't respond to friend requests. Save a few bits and don't bother. I'll just end up rejecting anyways.*
    * How to get EFFECTIVE help: The Hitchhiker's Guide to Getting Help at VBF - Removing eels from your hovercraft *
    * How to Use Parameters * Create Disconnected ADO Recordset Clones * Set your VB6 ActiveX Compatibility * Get rid of those pesky VB Line Numbers * I swear I saved my data, where'd it run off to??? *

  9. #9
    Discovering Life Siddharth Rout's Avatar
    Join Date
    Feb 2005
    Location
    Mumbai, India
    Posts
    12,001

    Re: Outlook being open and detecting it.

    You are doing it incorrectly. Please refer to my last post. You need to use appropriate error handling.
    A good exercise for the Heart is to bend down and help another up...
    Please Mark your Thread "Resolved", if the query is solved


    MyGear:
    ★ CPU ★ Ryzen 5 5800X
    ★ GPU ★ NVIDIA GeForce RTX 3080 TI Founder Edition
    ★ RAM ★ G. Skill Trident Z RGB 32GB 3600MHz
    ★ MB ★ ASUS TUF GAMING X570 (WI-FI) ATX Gaming
    ★ Storage ★ SSD SB-ROCKET-1TB + SEAGATE 2TB Barracuda IHD
    ★ Cooling ★ NOCTUA NH-D15 CHROMAX BLACK 140mm + 10 of Noctua NF-F12 PWM
    ★ PSU ★ ANTEC HCG-1000-EXTREME 1000 Watt 80 Plus Gold Fully Modular PSU
    ★ Case ★ LIAN LI PC-O11 DYNAMIC XL ROG (BLACK) (G99.O11DXL-X)
    ★ Monitor ★ LG Ultragear 27" 240Hz Gaming Monitor
    ★ Keyboard ★ TVS Electronics Gold Keyboard
    ★ Mouse ★ Logitech G502 Hero

  10. #10
    Smooth Moperator techgnome's Avatar
    Join Date
    May 2002
    Posts
    34,532

    Re: Outlook being open and detecting it.

    actually, he is using appropriate error handling... bot the GetObject and CreateObject will ERROR with 429 if Outlook isn't installed... so the single error handler is probably OK... I'd structure it a little differently so the error only happens once instead of twice, but that's just me.


    Now, what he IS missing is the check between Get and Create... if Get returned a valid object, then calling Create will disrupt it...

    -tg
    * I don't respond to private (PM) requests for help. It's not conducive to the general learning of others.*
    * I also don't respond to friend requests. Save a few bits and don't bother. I'll just end up rejecting anyways.*
    * How to get EFFECTIVE help: The Hitchhiker's Guide to Getting Help at VBF - Removing eels from your hovercraft *
    * How to Use Parameters * Create Disconnected ADO Recordset Clones * Set your VB6 ActiveX Compatibility * Get rid of those pesky VB Line Numbers * I swear I saved my data, where'd it run off to??? *

  11. #11
    Discovering Life Siddharth Rout's Avatar
    Join Date
    Feb 2005
    Location
    Mumbai, India
    Posts
    12,001

    Re: Outlook being open and detecting it.

    @TG: True but My error handler takes care of all 3 scenarios and hence the code that I gave above will not break.
    A good exercise for the Heart is to bend down and help another up...
    Please Mark your Thread "Resolved", if the query is solved


    MyGear:
    ★ CPU ★ Ryzen 5 5800X
    ★ GPU ★ NVIDIA GeForce RTX 3080 TI Founder Edition
    ★ RAM ★ G. Skill Trident Z RGB 32GB 3600MHz
    ★ MB ★ ASUS TUF GAMING X570 (WI-FI) ATX Gaming
    ★ Storage ★ SSD SB-ROCKET-1TB + SEAGATE 2TB Barracuda IHD
    ★ Cooling ★ NOCTUA NH-D15 CHROMAX BLACK 140mm + 10 of Noctua NF-F12 PWM
    ★ PSU ★ ANTEC HCG-1000-EXTREME 1000 Watt 80 Plus Gold Fully Modular PSU
    ★ Case ★ LIAN LI PC-O11 DYNAMIC XL ROG (BLACK) (G99.O11DXL-X)
    ★ Monitor ★ LG Ultragear 27" 240Hz Gaming Monitor
    ★ Keyboard ★ TVS Electronics Gold Keyboard
    ★ Mouse ★ Logitech G502 Hero

  12. #12

    Thread Starter
    Addicted Member
    Join Date
    Jun 2006
    Location
    Texas
    Posts
    162

    Re: Outlook being open and detecting it.

    I don't think it is in the error handling. I step through the code to see its progress and errors, if any. I get error 429 on the GetObject whether Outlook currently running or not. I need to detect not just installed but actually running. I cut and pasted your code into a new empty project and get same results. The CreateObject does work and tell you that it is installed, but the GetObject does not work. It always errors to 429.

  13. #13
    Discovering Life Siddharth Rout's Avatar
    Join Date
    Feb 2005
    Location
    Mumbai, India
    Posts
    12,001

    Re: Outlook being open and detecting it.

    Do you mean to say if Outlook is running then the GetObject Line is not getting you the Outlook Object and it moves on to the next line to run the CreateObject?
    A good exercise for the Heart is to bend down and help another up...
    Please Mark your Thread "Resolved", if the query is solved


    MyGear:
    ★ CPU ★ Ryzen 5 5800X
    ★ GPU ★ NVIDIA GeForce RTX 3080 TI Founder Edition
    ★ RAM ★ G. Skill Trident Z RGB 32GB 3600MHz
    ★ MB ★ ASUS TUF GAMING X570 (WI-FI) ATX Gaming
    ★ Storage ★ SSD SB-ROCKET-1TB + SEAGATE 2TB Barracuda IHD
    ★ Cooling ★ NOCTUA NH-D15 CHROMAX BLACK 140mm + 10 of Noctua NF-F12 PWM
    ★ PSU ★ ANTEC HCG-1000-EXTREME 1000 Watt 80 Plus Gold Fully Modular PSU
    ★ Case ★ LIAN LI PC-O11 DYNAMIC XL ROG (BLACK) (G99.O11DXL-X)
    ★ Monitor ★ LG Ultragear 27" 240Hz Gaming Monitor
    ★ Keyboard ★ TVS Electronics Gold Keyboard
    ★ Mouse ★ Logitech G502 Hero

  14. #14

    Thread Starter
    Addicted Member
    Join Date
    Jun 2006
    Location
    Texas
    Posts
    162

    Re: Outlook being open and detecting it.

    It does move to the next line, but if you check the err it is generating a 429 every time, OL running OR not.

    Add an X=Err.Number and watch it.

    Run code without OL running (but is installed) and X becomes 429. Then start up OL and run again. Guess what, X becomes 429 again. That is my issue. How to detect OL actually 'live' not just installed.
    Last edited by mickeykelley; Oct 10th, 2013 at 02:15 PM.

  15. #15
    Discovering Life Siddharth Rout's Avatar
    Join Date
    Feb 2005
    Location
    Mumbai, India
    Posts
    12,001

    Re: Outlook being open and detecting it.

    This is really surprising as I am unable to reproduce it. This is the first time I have come across when GetObject doesn't get you the instance of the open Application. I will have to think about this more as to why this is happening.
    A good exercise for the Heart is to bend down and help another up...
    Please Mark your Thread "Resolved", if the query is solved


    MyGear:
    ★ CPU ★ Ryzen 5 5800X
    ★ GPU ★ NVIDIA GeForce RTX 3080 TI Founder Edition
    ★ RAM ★ G. Skill Trident Z RGB 32GB 3600MHz
    ★ MB ★ ASUS TUF GAMING X570 (WI-FI) ATX Gaming
    ★ Storage ★ SSD SB-ROCKET-1TB + SEAGATE 2TB Barracuda IHD
    ★ Cooling ★ NOCTUA NH-D15 CHROMAX BLACK 140mm + 10 of Noctua NF-F12 PWM
    ★ PSU ★ ANTEC HCG-1000-EXTREME 1000 Watt 80 Plus Gold Fully Modular PSU
    ★ Case ★ LIAN LI PC-O11 DYNAMIC XL ROG (BLACK) (G99.O11DXL-X)
    ★ Monitor ★ LG Ultragear 27" 240Hz Gaming Monitor
    ★ Keyboard ★ TVS Electronics Gold Keyboard
    ★ Mouse ★ Logitech G502 Hero

  16. #16
    Discovering Life Siddharth Rout's Avatar
    Join Date
    Feb 2005
    Location
    Mumbai, India
    Posts
    12,001

    Re: Outlook being open and detecting it.

    Wait.. Are you using MS Office 2003? If yes then you might want to see this?

    http://support.microsoft.com/kb/238610
    A good exercise for the Heart is to bend down and help another up...
    Please Mark your Thread "Resolved", if the query is solved


    MyGear:
    ★ CPU ★ Ryzen 5 5800X
    ★ GPU ★ NVIDIA GeForce RTX 3080 TI Founder Edition
    ★ RAM ★ G. Skill Trident Z RGB 32GB 3600MHz
    ★ MB ★ ASUS TUF GAMING X570 (WI-FI) ATX Gaming
    ★ Storage ★ SSD SB-ROCKET-1TB + SEAGATE 2TB Barracuda IHD
    ★ Cooling ★ NOCTUA NH-D15 CHROMAX BLACK 140mm + 10 of Noctua NF-F12 PWM
    ★ PSU ★ ANTEC HCG-1000-EXTREME 1000 Watt 80 Plus Gold Fully Modular PSU
    ★ Case ★ LIAN LI PC-O11 DYNAMIC XL ROG (BLACK) (G99.O11DXL-X)
    ★ Monitor ★ LG Ultragear 27" 240Hz Gaming Monitor
    ★ Keyboard ★ TVS Electronics Gold Keyboard
    ★ Mouse ★ Logitech G502 Hero

  17. #17

    Thread Starter
    Addicted Member
    Join Date
    Jun 2006
    Location
    Texas
    Posts
    162

    Re: Outlook being open and detecting it.

    Again, I'm in VB6 and maybe VB.Net handles it differently. You did test in VB6 to reproduce?

  18. #18

    Thread Starter
    Addicted Member
    Join Date
    Jun 2006
    Location
    Texas
    Posts
    162

    Re: Outlook being open and detecting it.

    Nope, 2007. But different customers may be using different versions of OL.

  19. #19
    Discovering Life Siddharth Rout's Avatar
    Join Date
    Feb 2005
    Location
    Mumbai, India
    Posts
    12,001

    Re: Outlook being open and detecting it.

    Though the "Applies To" in the above link doesn't mention "MS Outlook" but the behavior is exactly the same.
    A good exercise for the Heart is to bend down and help another up...
    Please Mark your Thread "Resolved", if the query is solved


    MyGear:
    ★ CPU ★ Ryzen 5 5800X
    ★ GPU ★ NVIDIA GeForce RTX 3080 TI Founder Edition
    ★ RAM ★ G. Skill Trident Z RGB 32GB 3600MHz
    ★ MB ★ ASUS TUF GAMING X570 (WI-FI) ATX Gaming
    ★ Storage ★ SSD SB-ROCKET-1TB + SEAGATE 2TB Barracuda IHD
    ★ Cooling ★ NOCTUA NH-D15 CHROMAX BLACK 140mm + 10 of Noctua NF-F12 PWM
    ★ PSU ★ ANTEC HCG-1000-EXTREME 1000 Watt 80 Plus Gold Fully Modular PSU
    ★ Case ★ LIAN LI PC-O11 DYNAMIC XL ROG (BLACK) (G99.O11DXL-X)
    ★ Monitor ★ LG Ultragear 27" 240Hz Gaming Monitor
    ★ Keyboard ★ TVS Electronics Gold Keyboard
    ★ Mouse ★ Logitech G502 Hero

  20. #20

    Thread Starter
    Addicted Member
    Join Date
    Jun 2006
    Location
    Texas
    Posts
    162

    Re: Outlook being open and detecting it.

    What I basically read was that give it time to shift focus away from OL, so I added the Me.Focus and same things. So I started OL and then multiple other programs AND went to bathroom to give it plenty of time and same thing.

  21. #21
    Smooth Moperator techgnome's Avatar
    Join Date
    May 2002
    Posts
    34,532

    Re: Outlook being open and detecting it.

    I found an thread on MSDN that talked about this problem http://answers.microsoft.com/en-us/o...0-95a9680000f8
    it too pointed at the same KB Article - http://support.microsoft.com/?scid=k...8610&x=10&y=11

    Doesn't seem to be a solution... I see a lot of people having the same problem, but no one with the "AH HA! I found it!" post...

    -tg
    * I don't respond to private (PM) requests for help. It's not conducive to the general learning of others.*
    * I also don't respond to friend requests. Save a few bits and don't bother. I'll just end up rejecting anyways.*
    * How to get EFFECTIVE help: The Hitchhiker's Guide to Getting Help at VBF - Removing eels from your hovercraft *
    * How to Use Parameters * Create Disconnected ADO Recordset Clones * Set your VB6 ActiveX Compatibility * Get rid of those pesky VB Line Numbers * I swear I saved my data, where'd it run off to??? *

  22. #22
    Smooth Moperator techgnome's Avatar
    Join Date
    May 2002
    Posts
    34,532

    Re: Outlook being open and detecting it.

    Just for fun.... can you run Outlook As Administrator... see if that changes anything?

    -tg
    * I don't respond to private (PM) requests for help. It's not conducive to the general learning of others.*
    * I also don't respond to friend requests. Save a few bits and don't bother. I'll just end up rejecting anyways.*
    * How to get EFFECTIVE help: The Hitchhiker's Guide to Getting Help at VBF - Removing eels from your hovercraft *
    * How to Use Parameters * Create Disconnected ADO Recordset Clones * Set your VB6 ActiveX Compatibility * Get rid of those pesky VB Line Numbers * I swear I saved my data, where'd it run off to??? *

  23. #23
    Discovering Life Siddharth Rout's Avatar
    Join Date
    Feb 2005
    Location
    Mumbai, India
    Posts
    12,001

    Re: Outlook being open and detecting it.

    Wait.. I have another theory. Let me test it before posting...
    A good exercise for the Heart is to bend down and help another up...
    Please Mark your Thread "Resolved", if the query is solved


    MyGear:
    ★ CPU ★ Ryzen 5 5800X
    ★ GPU ★ NVIDIA GeForce RTX 3080 TI Founder Edition
    ★ RAM ★ G. Skill Trident Z RGB 32GB 3600MHz
    ★ MB ★ ASUS TUF GAMING X570 (WI-FI) ATX Gaming
    ★ Storage ★ SSD SB-ROCKET-1TB + SEAGATE 2TB Barracuda IHD
    ★ Cooling ★ NOCTUA NH-D15 CHROMAX BLACK 140mm + 10 of Noctua NF-F12 PWM
    ★ PSU ★ ANTEC HCG-1000-EXTREME 1000 Watt 80 Plus Gold Fully Modular PSU
    ★ Case ★ LIAN LI PC-O11 DYNAMIC XL ROG (BLACK) (G99.O11DXL-X)
    ★ Monitor ★ LG Ultragear 27" 240Hz Gaming Monitor
    ★ Keyboard ★ TVS Electronics Gold Keyboard
    ★ Mouse ★ Logitech G502 Hero

  24. #24

    Thread Starter
    Addicted Member
    Join Date
    Jun 2006
    Location
    Texas
    Posts
    162

    Re: Outlook being open and detecting it.

    Quote Originally Posted by techgnome View Post
    Just for fun.... can you run Outlook As Administrator... see if that changes anything?

    -tg
    Works.........You are on to something......

  25. #25
    Discovering Life Siddharth Rout's Avatar
    Join Date
    Feb 2005
    Location
    Mumbai, India
    Posts
    12,001

    Re: Outlook being open and detecting it.

    Well, I'll be dammed! Nice find tg
    A good exercise for the Heart is to bend down and help another up...
    Please Mark your Thread "Resolved", if the query is solved


    MyGear:
    ★ CPU ★ Ryzen 5 5800X
    ★ GPU ★ NVIDIA GeForce RTX 3080 TI Founder Edition
    ★ RAM ★ G. Skill Trident Z RGB 32GB 3600MHz
    ★ MB ★ ASUS TUF GAMING X570 (WI-FI) ATX Gaming
    ★ Storage ★ SSD SB-ROCKET-1TB + SEAGATE 2TB Barracuda IHD
    ★ Cooling ★ NOCTUA NH-D15 CHROMAX BLACK 140mm + 10 of Noctua NF-F12 PWM
    ★ PSU ★ ANTEC HCG-1000-EXTREME 1000 Watt 80 Plus Gold Fully Modular PSU
    ★ Case ★ LIAN LI PC-O11 DYNAMIC XL ROG (BLACK) (G99.O11DXL-X)
    ★ Monitor ★ LG Ultragear 27" 240Hz Gaming Monitor
    ★ Keyboard ★ TVS Electronics Gold Keyboard
    ★ Mouse ★ Logitech G502 Hero

  26. #26
    Discovering Life Siddharth Rout's Avatar
    Join Date
    Feb 2005
    Location
    Mumbai, India
    Posts
    12,001

    Re: Outlook being open and detecting it.

    Ok I also tested my theory and it works

    Try this (Admin or no Admin!)

    Code:
    Private Declare Function FindWindow Lib "user32" Alias "FindWindowA" _
    (ByVal lpClassName As String, ByVal lpWindowName As String) As Long
    
    Private Sub Sample()
        Dim Ret As Long
    
        Ret = FindWindow(vbNullString, "Microsoft Outlook")
    
        If Ret <> 0 Then
            MsgBox "Outlook is running"
        End If
    End Sub
    A good exercise for the Heart is to bend down and help another up...
    Please Mark your Thread "Resolved", if the query is solved


    MyGear:
    ★ CPU ★ Ryzen 5 5800X
    ★ GPU ★ NVIDIA GeForce RTX 3080 TI Founder Edition
    ★ RAM ★ G. Skill Trident Z RGB 32GB 3600MHz
    ★ MB ★ ASUS TUF GAMING X570 (WI-FI) ATX Gaming
    ★ Storage ★ SSD SB-ROCKET-1TB + SEAGATE 2TB Barracuda IHD
    ★ Cooling ★ NOCTUA NH-D15 CHROMAX BLACK 140mm + 10 of Noctua NF-F12 PWM
    ★ PSU ★ ANTEC HCG-1000-EXTREME 1000 Watt 80 Plus Gold Fully Modular PSU
    ★ Case ★ LIAN LI PC-O11 DYNAMIC XL ROG (BLACK) (G99.O11DXL-X)
    ★ Monitor ★ LG Ultragear 27" 240Hz Gaming Monitor
    ★ Keyboard ★ TVS Electronics Gold Keyboard
    ★ Mouse ★ Logitech G502 Hero

  27. #27

    Thread Starter
    Addicted Member
    Join Date
    Jun 2006
    Location
    Texas
    Posts
    162

    Re: Outlook being open and detecting it.

    Yep that seems to work perfectly. Now how to make users always start OL as Administrator. Maybe that also explains how we have seen some users it working and some not. Maybe in XP administrator not an issue or some do have setup to run as admin. But ultimately, I cannot truly test if running.

  28. #28

    Thread Starter
    Addicted Member
    Join Date
    Jun 2006
    Location
    Texas
    Posts
    162

    Re: Outlook being open and detecting it.

    Quote Originally Posted by Siddharth Rout View Post
    Ok I also tested my theory and it works

    Try this (Admin or no Admin!)

    Code:
    Private Declare Function FindWindow Lib "user32" Alias "FindWindowA" _
    (ByVal lpClassName As String, ByVal lpWindowName As String) As Long
    
    Private Sub Sample()
        Dim Ret As Long
    
        Ret = FindWindow(vbNullString, "Microsoft Outlook")
    
        If Ret <> 0 Then
            MsgBox "Outlook is running"
        End If
    End Sub
    So that doesn't even use the OL calls.....interesting. Let me play with it.

  29. #29

    Thread Starter
    Addicted Member
    Join Date
    Jun 2006
    Location
    Texas
    Posts
    162

    Re: Outlook being open and detecting it.

    SR, that works good and admin or not. Had not really even thought to look that area. I was just hung up on the call that is supposed to work.

    Now we have an answer as to what is going on and a work around. Thanks guys.

  30. #30
    Discovering Life Siddharth Rout's Avatar
    Join Date
    Feb 2005
    Location
    Mumbai, India
    Posts
    12,001

    Re: [RESOLVED] Outlook being open and detecting it.

    Quote Originally Posted by mickeykelley View Post
    SR, that works good and admin or not. Had not really even thought to look that area. I was just hung up on the call that is supposed to work.

    Now we have an answer as to what is going on and a work around. Thanks guys.
    All's well that ends well
    A good exercise for the Heart is to bend down and help another up...
    Please Mark your Thread "Resolved", if the query is solved


    MyGear:
    ★ CPU ★ Ryzen 5 5800X
    ★ GPU ★ NVIDIA GeForce RTX 3080 TI Founder Edition
    ★ RAM ★ G. Skill Trident Z RGB 32GB 3600MHz
    ★ MB ★ ASUS TUF GAMING X570 (WI-FI) ATX Gaming
    ★ Storage ★ SSD SB-ROCKET-1TB + SEAGATE 2TB Barracuda IHD
    ★ Cooling ★ NOCTUA NH-D15 CHROMAX BLACK 140mm + 10 of Noctua NF-F12 PWM
    ★ PSU ★ ANTEC HCG-1000-EXTREME 1000 Watt 80 Plus Gold Fully Modular PSU
    ★ Case ★ LIAN LI PC-O11 DYNAMIC XL ROG (BLACK) (G99.O11DXL-X)
    ★ Monitor ★ LG Ultragear 27" 240Hz Gaming Monitor
    ★ Keyboard ★ TVS Electronics Gold Keyboard
    ★ Mouse ★ Logitech G502 Hero

  31. #31

    Thread Starter
    Addicted Member
    Join Date
    Jun 2006
    Location
    Texas
    Posts
    162

    Re: [RESOLVED] Outlook being open and detecting it.

    Still not really working like I need. I need to be in my program AND Outlook be opened or closed. If Outlook has already been started by a user and then starts our program, all the above samples don't work because trying to use the CreateObject("Outlook.Application") will just set to nothing. The telling if OL is not installed or not works fine. But if my program is running and does detect OL and then OL is started, I get message from OL saying "Cannot start Microsoft Office Outlook. A program error occurred. ......". Post # above generates an err 429 for both the GetObject and CreateObject BUT if OL is already opened the Set OutApp = CreateObject("Outlook.Application") sets to nothing so you cannot use OL because you end up with object not set.

  32. #32
    PowerPoster Nightwalker83's Avatar
    Join Date
    Dec 2001
    Location
    Adelaide, Australia
    Posts
    13,344

    Re: [RESOLVED] Outlook being open and detecting it.

    If I understand correctly you need to detect from your program whether or not Outlook is running and if so exit your program else run outlook from within your program.
    when you quote a post could you please do it via the "Reply With Quote" button or if it multiple post click the "''+" button then "Reply With Quote" button.
    If this thread is finished with please mark it "Resolved" by selecting "Mark thread resolved" from the "Thread tools" drop-down menu.
    https://get.cryptobrowser.site/30/4111672

  33. #33
    PowerPoster
    Join Date
    Aug 2011
    Location
    B.C., Canada
    Posts
    2,887

    Re: [RESOLVED] Outlook being open and detecting it.

    Double post

  34. #34
    PowerPoster
    Join Date
    Aug 2011
    Location
    B.C., Canada
    Posts
    2,887

    Re: [RESOLVED] Outlook being open and detecting it.

    Why don't you look for the process name, if it exists then kill all outlook windows.
    Once all outlook windows are killed you start program and open a fresh new outlook object.

    Not sure if this is what you want?

  35. #35

    Thread Starter
    Addicted Member
    Join Date
    Jun 2006
    Location
    Texas
    Posts
    162

    Re: [RESOLVED] Outlook being open and detecting it.

    I can't kill it as some customers want outlook open at same 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
  •  



Click Here to Expand Forum to Full Width