Switch To..., Retry, Cancel

Well, as much as I hate to admit it, I was recently working on VB6 application that uses Office COM automation. It needed to have Word and Excel do a few things while the main application waited.

Every time a user clicked on the UI, you'd get that beautiful dialog "This application cannot be completed because the other application is busy. Choose 'Switch To' to activate the busy application and correct the problem.

This is particularly onerous because if the user does not click switch to, basically, both programs, the VB6 app AND the Office app sit around waiting for the user to do something. Yay!

Luckily I found the quick and dirty answer to this. Somewhere... Anywhere before the point that you make the COM call, just insert these two lines:

App.OleRequestPendingTimeout = 2147483647
App.OleServerBusyTimeout = 2147483647

... and you never have to see that dialog again.


1 comment:

Anonymous said...

Is there similar function or property in .Net.

I am facing same problem in C# window form when I am trying to save a huge word document