a g
08-30-2013, 09:44 AM
My first post :) If this post should be posted in the Outlook-thread, please move it.
I'm making a dashboard in Excel showing different kind of data from a outlook account/folder.
What I'm unable to do, is create a new Outlook.Application instance with events attached.
I have created a class module in my Excel workbook. My code looks like this:
Private WithEvents OA as Outlook.Application
Public Sub Class_Initialize()
On Error Resume Next
Set OA = GetObject("", "Outlook.Application")
If Err.Number <> 0 Then
Set OA = New Outlook.Application
Err.Clear
End If
End Sub
If I remove the WithEvents in the declaration, this code work just fine.
Anyone got an explanation why I'm unable to create a Outlook object with events?
My Excel and Outlook version is 2013 (PC)
I'm making a dashboard in Excel showing different kind of data from a outlook account/folder.
What I'm unable to do, is create a new Outlook.Application instance with events attached.
I have created a class module in my Excel workbook. My code looks like this:
Private WithEvents OA as Outlook.Application
Public Sub Class_Initialize()
On Error Resume Next
Set OA = GetObject("", "Outlook.Application")
If Err.Number <> 0 Then
Set OA = New Outlook.Application
Err.Clear
End If
End Sub
If I remove the WithEvents in the declaration, this code work just fine.
Anyone got an explanation why I'm unable to create a Outlook object with events?
My Excel and Outlook version is 2013 (PC)