Reputation: 2729
I'm receiving Error 429 'Active X Component Can't create the object' when I start Outlook 2013. While debugging I found it was occurring at Set oOutlook = New Outlook.Application
. But when I run the code after Outlook is started it works fine. Any idea why this is occurring?
Option Explicit
Private WithEvents oOutlook As Outlook.Application
Private WithEvents oMailItems As Outlook.Items
Private ns As NameSpace
Private Inbox As MAPIFolder
Private InboxItems As Outlook.Items
Private FailNotice As MAPIFolder
Private zsForwardTo As String
Private Sub Class_Initialize()
Set ns = GetNamespace("MAPI")
Set Inbox = ns.GetDefaultFolder(olFolderInbox)
Set InboxItems = Inbox.Items
Set oOutlook = New Outlook.Application
Set oMailItems = oOutlook.Session.GetDefaultFolder(olFolderInbox).Items
Set FailNotice = Inbox.Folders("Fail Notices")
End Sub
Upvotes: 2
Views: 3343
Reputation: 3732
Based on Max's comment, I wanted to post an answer because this was really helpful and I couldn't find this anywhere else on the web. Max wrote:
I had a simular problem, I think Outlook is having a problem wirh creating a new instance while it is not fully started itself. In the end i did not create a new application but worked in the existing one.
I wasn't sure how to use the existing application, but I got it working like this: the oOutlook variable is now unnecessary and can be replaced by the simple word "Application". The revised code would look like this:
Option Explicit
Private WithEvents oMailItems As Outlook.Items
Private ns As NameSpace
Private Inbox As MAPIFolder
Private InboxItems As Outlook.Items
Private FailNotice As MAPIFolder
Private zsForwardTo As String
Private Sub Class_Initialize()
Set ns = GetNamespace("MAPI")
Set Inbox = ns.GetDefaultFolder(olFolderInbox)
Set InboxItems = Inbox.Items
Set oMailItems = Application.Session.GetDefaultFolder(olFolderInbox).Items
Set FailNotice = Inbox.Folders("Fail Notices")
End Sub
Upvotes: 1