richh
Board Regular
- Joined
- Jun 24, 2007
- Messages
- 245
- Office Version
- 365
- 2016
I have a stock function I use to test to see if Outlook is running before I attempt to draft an email. I've never had problems with it before, but today I ran the program and it doesn't acknowledge that Outlook is running. If I close/reopen the file, it seems to work and if I step through, it'll work as well. I also have a user who states she's having the same problem. I'm running Office 2010.
Code:
Public Function TestOutlookIsOpen(row As Long) As Integer
Dim oOutlook As Object
On Error Resume Next
Set oOutlook = GetObject(, "Outlook.Application")
On Error GoTo 0
If oOutlook Is Nothing Then '//The program will occasionally see oOutlook as being empty.
TestOutlookIsOpen = -1
MsgBox "Outlook is not running. Open Outlook and try again."
Else
If row <> -1 Then
Call createEmail(row)
TestOutlookIsOpen = 1 '//Some of my code first tests if Outlook is open and then performs tasks after, the rest do it up front and then tests.
End If
End If
End Function
Last edited by a moderator: