Microsoft KB Archive/240809

= How to prevent the "Switch To" or "Application Busy" error messages using OLE Automation =

Article ID: 240809

Article Last Modified on 2/24/2005

-

APPLIES TO


 * Microsoft Visual FoxPro 5.0 Standard Edition
 * Microsoft Visual FoxPro 6.0 Professional Edition
 * Microsoft Visual FoxPro 7.0 Professional Edition
 * Microsoft Visual FoxPro 8.0 Professional Edition
 * Microsoft Visual FoxPro 9.0 Professional Edition

-



This article was previously published under Q240809



SUMMARY
Using OLE automation with another application, such as Microsoft Word, you may receive the following error message if you are using Microsoft Windows NT 4.0, Windows 2000, Windows XP, or Windows Server 2003:

This action cannot be completed because the other application is busy. Choose 'Switch To' to activate the busy application and correct the problem.

If you are using Windows 95 and Windows 98, you receive the following error message:

This action could not be completed because the other program is busy. Click the appropriate button on the taskbar to activate the program and correct the problem.



MORE INFORMATION
This error message usually occurs because the OLE activated application has an open dialog box and is expecting user input. This error message can be eliminated by using the property OLERequestPendingTimeout. This property specifies the amount of time after an Automation request is made before a busy message is displayed. The default is five seconds and is specified in milliseconds. By setting the timeout to 0, Microsoft Visual FoxPro will wait indefinitely for the other application. The busy message will not be displayed whether the Automation request is pending or if a mouse or keyboard event occurs.   Create a program and enter the following code. oWord=CREATEOBJECT("Word.Application") APPLICATION.OLERequestPendingTimeout = 0  && 0 means no busy error message WITH oword                                && Change to 100 to see busy && message .Documents.ADD .Dialogs(88).SHOW                      && Open the Word Print dialog .APPLICATION.QUIT(0)                   && Quit and don't save changes ENDWITH  Run the program and click on the Microsoft Visual FoxPro window after the Word Print dialog box appears. You will not see the error messages mentioned prior. To see the error message, change the OLERequestPendingTimeout to a relatively low number such as 100. Run the code again and click the Microsoft Visual FoxPro window after the Microsoft Word Print dialog box appears. Now one of the messages that is listed in the "Summary" section appears.

