Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
427 views
in Technique[技术] by (71.8m points)

com - CreateObject on Outlook.Application fails on Outlook 2010 when Outlook is running under a different account

The problem I'm running into is already described at Getting/Creating an Outlook Application in Windows 7 but I had a very hard time identifying the source of the problem because I happen to be maintaining an old VB6 application at the moment, and the errors that are reported from VB6 applications are not mentioned in that article. Furthermore, I'm looking for better solutions.

The problem is that CreateObject("Outlook.Application") and GetObject(,"Outlook.Application") are failing with Error 429 - ActiveX component can't create object, particularly on Windows 7. The source of the problem turns out to be that if Outlook is already running under a normal user account and an application is running as an administrator (not unheard of for old 32-bit applications running on Windows 7) wants to access Outlook, the request for an Outlook COM interface hangs for 30 seconds and then fails. It seems to be related to the fact that the requested instance of Outlook and the already-running instance of Outlook are using different user accounts or privileges.

It would be nice, first of all, if a better error could be reported, and if it could be reported more quickly. Usually the application hangs for 30 seconds before reporting the error. So the first question is, is there any way to detect this condition without waiting 30 seconds?

Next, is there any way to work around this error so we don't have to care that Outlook might already be running under different credentials when we want to access the Outlook API? One thought is turning off UAC so that the old 32-bit application is less likely to need to be running as administrator. Is there a better solution?

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)

I assume you 've alredy resolved this, but just in case, i had the same proble and the solution for me was to terminate the procces outlook.exe with an API and then do "CreateObject"

you can do what is next: if err.number = 429 then terminateprocces ("outlook.exe") 'u can find function code on intenet resume end if


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...