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

Article translations Article translations
Article ID: 240809 - View products that this article applies to.
This article was previously published under Q240809
Expand all | Collapse all

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.
  1. 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
    						
  2. 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.
  3. To see the error message, change the OLERequestPendingTimeout to a relatively low number such as 100.
  4. 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.

REFERENCES

Visual FoxPro Online Help, version 6.0; Search for "OLERequestPendingTimeout"

Properties

Article ID: 240809 - Last Review: February 24, 2005 - Revision: 3.4
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
Keywords: 
kbautomation kbcodesnippet kbhowto KB240809

Give Feedback

 

Contact us for more help

Contact us for more help
Connect with Answer Desk for expert help.
Get more support from smallbusiness.support.microsoft.com