0

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?

Community
  • 1
  • 1
BlueMonkMN
  • 25,079
  • 9
  • 80
  • 146
  • I'm using `FindWindow("rctrl_renwnd32", vbNullString) <> 0` to check if Outlook is running. If so and `CreateObject` fails then it's fairly plausible that there is an integrity level mismatch. – wqw Jan 16 '15 at 15:40
  • That's not much better than assuming that a CreateObject failure is a result of this problem regardless of the FindWindow result. It still entails a 30 second delay. – BlueMonkMN Jan 16 '15 at 15:42
  • There is no other way. – Eugene Astafiev Jan 16 '15 at 16:01
  • If you can find the window then maybe this code would help you find out if it was elevated: http://stackoverflow.com/questions/95912/how-can-i-detect-if-my-process-is-running-uac-elevated-or-not – Rob Jan 16 '15 at 16:14
  • Just posted a VB6 implementation of `IsElevated` to thread above. – wqw Jan 16 '15 at 16:51
  • @BlueMonkMN: `CreateObject` will fail 99% of the time because Outlook is not installed at all. You can safely assume in the rest 1% of the cases that **if it's running** then you have a case of integrity mismatch. – wqw Jan 16 '15 at 16:54
  • @wqw Since it's up to the user to resolve the problem anyway, there's little point in trying to distinguish why the error is being reported. Simpler to just skip the FindWindow check and report an error with two possible explanations. It will likely be obvious to the user which explanation is correct - they can probably tell if they're already running Outlook or not pretty easily, and maybe more reliably. That is, if you're going to call CreateObject to confirm the error anyway. – BlueMonkMN Jan 16 '15 at 17:02
  • You might use Simple MAPI if Outlook is not installed that's why I usually need to discern both cases. Simple MAPI fails too on elevation mismatch nothing to do but to inform the user for the failure. Btw, I don't observe 30 seconds timeout on Win8 / Win8.1 -- more like 5 seconds. – wqw Jan 16 '15 at 17:07

2 Answers2

1

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

Gonzalo
  • 185
  • 1
  • 12
0

I solved this issue by installing the VB6 application locally instead of on a network drive. Unchecking Run As administrator in the shortcut properties may have helped.

Kirsten
  • 15,730
  • 41
  • 179
  • 318