Chris Raisin
asked on
Runtime Error 429 - Activex component can't create object
I wrote a program in VB6 which ran fine under Windows XP, using ClickYes Pro to avoid the security error messages in Outlook while accessing Outlook's Calendar.
Under Windows 7 however I get an error message "Activex component can't create object" ONLY IF Outlook is currently running!
If Outlook is closed the code runs fine, but as soon as Outlook is open (minimized or not)
and I run my code, the error appears.
Can anyone shed some light on how to get around this?
A segment of the code experiencing the error follows:
========================== ========== ========== ========== ========== ===
Dim myOlApp As New Outlook.Application
Dim myNS As NameSpace
Set myNS = myOlApp.GetNamespace("MAPI ") '<<--- Error if Outlook already open
========================== ========== ========== ========== ========== ==
Under Windows 7 however I get an error message "Activex component can't create object" ONLY IF Outlook is currently running!
If Outlook is closed the code runs fine, but as soon as Outlook is open (minimized or not)
and I run my code, the error appears.
Can anyone shed some light on how to get around this?
A segment of the code experiencing the error follows:
==========================
Dim myOlApp As New Outlook.Application
Dim myNS As NameSpace
Set myNS = myOlApp.GetNamespace("MAPI
==========================
ASKER
No, I was using Outlook 2010 under the old system as well.
I just tested the following. Win 7, Outlook 2007. VBA procedure in Access 2007. Originally written in Access 2003 on Win XP. It works correctly with references updated.
OM Gang
Public Sub Test_OutlookTasks()
On Error GoTo Err_Test_OutlookTasks
'declare and open instance of MS Outlook
Dim olOutlook As New Outlook.Application
Dim olNS As Outlook.NameSpace
Dim olFolders As Outlook.MAPIFolder
Dim olSubFolders As Outlook.MAPIFolder
Dim olContacts As Outlook.MAPIFolder
Dim olTasks As Outlook.MAPIFolder
Dim olCalendar As Outlook.MAPIFolder
Dim olSubCal As Outlook.MAPIFolder
Dim olItems As Outlook.Items
Dim olConItem As Outlook.ContactItem
Dim olTaskItem As Outlook.TaskItem
Dim olCalendarItem As Outlook.AppointmentItem
Dim olMailItem As Outlook.MailItem
Dim olAttachment As Outlook.Attachment
Dim olAttachments As Outlook.Attachments
Dim strPST As String
Dim strMailBox As String
Dim strCriteria As String
Dim intCounter As Integer
'assign name of outlook PST folder we want to use to string
'variable
strMailBox = "Mailbox - Gang, OM"
'set object Outlook NameSpace
Set olNS = olOutlook.GetNamespace("MA PI")
'set object NameSpace Folders for PST file
Set olFolders = olNS.Folders(strMailBox)
Set olSubFolders = olFolders.Folders("Infecte d Items")
Set olItems = olSubFolders.Items
'loop through list of items
For intCounter = 1 To olItems.Count
Set olMailItem = olItems(intCounter)
'delete all attachments from message
Set olAttachments = olMailItem.Attachments
While olAttachments.Count > 0
olAttachments.Remove 1
Wend
olMailItem.Save
Debug.Print olMailItem.Subject
Next intCounter
Exit_Test_OutlookTasks:
Set olAttachments = Nothing
Set olAttachment = Nothing
Set olMailItem = Nothing
Set olCalendarItem = Nothing
Set olTaskItem = Nothing
Set olTasks = Nothing
Set olConItem = Nothing
Set olItems = Nothing
Set olContacts = Nothing
Set olSubFolders = Nothing
Set olSubCal = Nothing
Set olFolders = Nothing
Set olNS = Nothing
Set olOutlook = Nothing
Exit Sub
Err_Test_OutlookTasks:
MsgBox Err.Number & ", " & Err.Description, , "Error'"
Resume Exit_Test_OutlookTasks
End Sub
OM Gang
Public Sub Test_OutlookTasks()
On Error GoTo Err_Test_OutlookTasks
'declare and open instance of MS Outlook
Dim olOutlook As New Outlook.Application
Dim olNS As Outlook.NameSpace
Dim olFolders As Outlook.MAPIFolder
Dim olSubFolders As Outlook.MAPIFolder
Dim olContacts As Outlook.MAPIFolder
Dim olTasks As Outlook.MAPIFolder
Dim olCalendar As Outlook.MAPIFolder
Dim olSubCal As Outlook.MAPIFolder
Dim olItems As Outlook.Items
Dim olConItem As Outlook.ContactItem
Dim olTaskItem As Outlook.TaskItem
Dim olCalendarItem As Outlook.AppointmentItem
Dim olMailItem As Outlook.MailItem
Dim olAttachment As Outlook.Attachment
Dim olAttachments As Outlook.Attachments
Dim strPST As String
Dim strMailBox As String
Dim strCriteria As String
Dim intCounter As Integer
'assign name of outlook PST folder we want to use to string
'variable
strMailBox = "Mailbox - Gang, OM"
'set object Outlook NameSpace
Set olNS = olOutlook.GetNamespace("MA
'set object NameSpace Folders for PST file
Set olFolders = olNS.Folders(strMailBox)
Set olSubFolders = olFolders.Folders("Infecte
Set olItems = olSubFolders.Items
'loop through list of items
For intCounter = 1 To olItems.Count
Set olMailItem = olItems(intCounter)
'delete all attachments from message
Set olAttachments = olMailItem.Attachments
While olAttachments.Count > 0
olAttachments.Remove 1
Wend
olMailItem.Save
Debug.Print olMailItem.Subject
Next intCounter
Exit_Test_OutlookTasks:
Set olAttachments = Nothing
Set olAttachment = Nothing
Set olMailItem = Nothing
Set olCalendarItem = Nothing
Set olTaskItem = Nothing
Set olTasks = Nothing
Set olConItem = Nothing
Set olItems = Nothing
Set olContacts = Nothing
Set olSubFolders = Nothing
Set olSubCal = Nothing
Set olFolders = Nothing
Set olNS = Nothing
Set olOutlook = Nothing
Exit Sub
Err_Test_OutlookTasks:
MsgBox Err.Number & ", " & Err.Description, , "Error'"
Resume Exit_Test_OutlookTasks
End Sub
I don't have Office 2010 immediately available but can test again at home this evening. Were you able to check references?
OM Gang
OM Gang
ASKER
I am using Outlook 2010.
As stated earlier, it will run OK provided Outlook 2010 is not running, otherwise it can't create the namespace. Could it be an "authority" problem?
I have turned off UAC.
Perhaps some one has some code that will close the current outlook, and then reopen it after my code has run? (it would be better though if I could just get around this).
As stated earlier, it will run OK provided Outlook 2010 is not running, otherwise it can't create the namespace. Could it be an "authority" problem?
I have turned off UAC.
Perhaps some one has some code that will close the current outlook, and then reopen it after my code has run? (it would be better though if I could just get around this).
See this regarding re-registering the registry entries for the Office application(s) on the machine to resolve Runtime error 429 errors. May be worth a shot.
OM Gang
http://answers.microsoft.com/en-us/windows/forum/windows_xp-windows_programs/runtime-error-429-activex-component-cant-create/481475c9-4ed6-4211-be6b-2431b962b257
OM Gang
http://answers.microsoft.com/en-us/windows/forum/windows_xp-windows_programs/runtime-error-429-activex-component-cant-create/481475c9-4ed6-4211-be6b-2431b962b257
Try running your application or run Outlook as Administrator.
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
Aha! Now I see how it works!....By accepting your own response, ZERO points are automatically awarded....clever, this software at EE :-)
ASKER
Just as a side note: I cannot guarantee that running VB6 as Administrator was the correct solution.
The problem was that the running of the OLD application (compiled under VB6 while still in XP environment) may have caused a change in environment which then allowed successful compile of VB6 under Windows 7. This is particularly possible, since a re-run NOT under administrator rights still compiled successfully.
I thought I had better explain why I did not award any points.
Thanks again everyone (when I say everyone, I mean, the two of you LOL) :-)
Cheers
Chris
The problem was that the running of the OLD application (compiled under VB6 while still in XP environment) may have caused a change in environment which then allowed successful compile of VB6 under Windows 7. This is particularly possible, since a re-run NOT under administrator rights still compiled successfully.
I thought I had better explain why I did not award any points.
Thanks again everyone (when I say everyone, I mean, the two of you LOL) :-)
Cheers
Chris
Glad you got it figured out.
OM Gang
OM Gang
ASKER
Solved the problem myself - It seems strange to award yourself points, but I guess the "points in" "points out" balances everything in the long run.
OM Gang