I am using the below code in an Excel file which can be accessed and used by multiple people. The extract checks to see if Outlook is open before proceeding with the rest of the code.
Dim oOutlook As Object
'Checks to see if Outlook is open
On Error Resume Next
Set oOutlook = GetObject(, "Outlook.Application")
On Error GoTo 0
If oOutlook Is Nothing Then
MsgBox "Outlook is not open."
Exit Sub
End If
Set oOutlook = Nothing
The code seems to work for everyone apart from one person/computer. For this one person/computer, even with Outlook open, the line of code
Set oOutlook = GetObject(, "Outlook.Application")
does not seem recognise that it is open. I've checked the usual things: made sure the VBA references are set up correctly, security settings seem to be the same as everyone else.
Any suggestions would be greatly appreciated.
In my experience, I use this to avoid this problem :
On Error Resume Next
Set oWord = GetObject(, "Word.Application")
If Err.Number <> 0 Then
Set oWord = CreateObject("Word.Application")
End If
On Error GoTo 0
But actually I have no clue where the issue come from... It just pass by for me sometimes!
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With