XL: Application.Interactive Value Not Reset When Macro Stops

Last reviewed: February 3, 1998
Article ID: Q151332
The information in this article applies to:
  • Microsoft Excel for Windows, versions 5.0, 5.0c
  • Microsoft Excel for Windows 95, version 7.0
  • Microsoft Excel for Windows NT, version 5.0
  • Microsoft Excel for the Macintosh, versions 5.0, 5.0a
  • Microsoft Excel for the Power Macintosh, versions 5.0, 5.0a
  • Microsoft Excel 97 for Windows
  • Microsoft Excel 98 Macintosh Edition

SYMPTOMS

Application.Interactive does not reset itself to a default value after the end of the macro is reached.

CAUSE

The Interactive property of the Application object allows a macro to block all user input from both the keyboard and the mouse. The property is useful in situations where user input has the potential to disrupt macro operations. However, unlike most of the Read/Write properties of the Microsoft Excel Application object, Application.Interactive does not reset itself to a default value after the end of the macro is reached. Because of this, if the interactive property is not reset back to a true value in the code of the macro, or an error occurs during execution of the macro, Microsoft Excel will not respond to user input even though the macro has technically stopped executing.

RESOLUTION

In the case where the user forgets to reset the property back to true, or the user encounters an error in the execution of the code, it will most likely be necessary to shut down that instance of Microsoft Excel and fix the line of code that caused the error.

Using CTRL+ALT+DELETE on Windows 95 and Windows NT and ending the Microsoft Excel task will accomplish this.

On the Apple Macintosh, the user will need to use OPTION+COMMAND+ESCAPE to force Microsoft Excel to quit.

Under Windows 3.x the user may be able to use CTRL+ALT+DELETE, but more often than not, because no "error" has occurred, the user will have to restart the machine.

Sample Visual Basic Procedure

Microsoft provides programming examples for illustration only, without warranty either expressed or implied, including, but not limited to, the implied warranties of merchantability and/or fitness for a particular purpose. This article assumes that you are familiar with the programming language being demonstrated and the tools used to create and debug procedures. Microsoft support engineers can help explain the functionality of a particular procedure, but they will not modify these examples to provide added functionality or construct procedures to meet your specific needs. If you have limited programming experience, you may want to contact the Microsoft fee-based consulting line at (800) 936-5200. For more information about the support options available from Microsoft, please see the following page on the World Wide Web:

   http://www.microsoft.com/support/supportnet/refguide/default.asp

In the event that it is necessary to enable user input to Microsoft Excel without a restart of the application, there is a method to reset the property using Automation through a Visual Basic for Applications macro.

NOTE: The success of the following macro depends on the ability to open a separate instance of Microsoft Excel. Under Windows 3.x, the number and complexity of applications that can be running concurrently is directly dependent on available System Resources. If the instance of Microsoft Excel that is not responding, or the instance the user is trying to open contains many worksheets, charts and so on, System Resources will be significantly reduced. In Microsoft Excel 98, you cannot start a separate instance of Microsoft Excel, and therefore must run the macro from another application.

The method for opening a separate instance of Microsoft Excel varies depending on the operating system.

Windows 3.x and Windows NT

  1. Use ALT+TAB to switch to Program Manager.

  2. Either double click the Microsoft Excel icon or click Run on the File menu. Type the complete path to the Microsoft Excel executable file, for example, "c:\Excel\Excel.exe", and then press ENTER.

Windows 95

  1. Click the Start button.

  2. Click Run, type the full path to Microsoft Excel in the Open box, for example, "c:\Excel\Excel.exe", and then press ENTER.

  3. In Microsoft Excel 97, point to Macro on the Tools menu, and then click Visual Basic Editor.

Microsoft Excel 5.0 on the Apple Macintosh

  1. Switch to Finder.

    Note: If you have Microsoft Office Manager installed from Microsoft Office and you have QuickSwitch enabled for the Microsoft Office Manager, you can press COMMAND+TAB to switch to Finder. Otherwise, you would have to click the Finder desktop or another program window in the background to switch to that application.

  2. Double-click the hard drive and locate the Microsoft Excel icon.

  3. Create a copy of the Microsoft Excel icon by holding down the Option button and dragging the icon to the desktop.

  4. Double-click the Microsoft Excel icon.

Once a separate instance of Microsoft Excel has been started using one of the methods listed above, follow these steps:

  1. On the Insert menu, click Module.

  2. Type the following code in the Module sheet.

          Sub reset_interactive()
    
             Dim xlobj As Object
    
             ' The GetObject method will access the open instance of Microsoft 
             ' Excel, not a new one.
             Set xlobj = GetObject("Book1")
    
             ' Where book1 is the name of the Workbook that has stopped 
             ' responding to user input. Make sure to leave the extension, 
             ' .xls, .xlt, and so on, off.
             ' Because the above line assigns the first Worksheet of book1 to 
             ' xlobj, we must access the Application property of the object in 
             ' order to reset the Interactive property.
    
             xlobj.Application.Interactive = True
    
          End Sub
    
    

  3. To run the macro, click the insertion point in the macro code, and then press F5.

Microsoft Excel 98 Macintosh Edition

As stated previously, you cannot start more than one instance of Microsoft Excel 98; therefore, you must run the Visual Basic for Applications Sub procedure from another Microsoft Office program. In this example, we will use Microsoft Word 98.

  1. Switch to Microsoft Word 98.

    Note: If you have Microsoft Office Manager installed from Microsoft Office and you have QuickSwitch enabled for the Microsoft Office Manager, you can press COMMAND+TAB to switch to Finder. Otherwise, you would have to click the Finder desktop or another program window in the background to switch to that application.

  2. On the Tools menu, point to Macro, and then click Visual Basic Editor.

  3. On the Insert menu, click Module.

  4. Type the following code in the Module sheet:

          Sub reset_interactive()
    
             Dim xlobj As Object
    
             ' The GetObject method will access the open instance of Microsoft 
             ' Excel.
             Set xlobj = GetObject(,"Excel.Application")
    
             ' Sets the Interactive property for the Excel application back to 
             ' True.
             xlobj.Interactive = True
    
          End Sub
    
    

  5. To run the macro, click the insertion point in the macro code, and then press F5.

STATUS

Microsoft has confirmed this to be a problem in the Microsoft products listed at the beginning of this article. We are researching this problem and will post new information here in the Microsoft Knowledge Base as it becomes available.

REFERENCES

"Microsoft Excel 5 Visual Basic for Applications Reference", version 5.0, page 342

"Microsoft Excel/Visual Basic Reference", second edition, page 394


Additional query words: 5.00 5.00a 5.00c 7.00
Keywords : kbcode kbole kbprg PgmOthr
Version : MACTINTOSH:5.00,98; WINDOWS:5.00,5.00c,7.00,97
Platform : MACINTOSH WINDOWS
Issue type : kbprb
Solution Type : kbworkaround


THE INFORMATION PROVIDED IN THE MICROSOFT KNOWLEDGE BASE IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY KIND. MICROSOFT DISCLAIMS ALL WARRANTIES, EITHER EXPRESS OR IMPLIED, INCLUDING THE WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. IN NO EVENT SHALL MICROSOFT CORPORATION OR ITS SUPPLIERS BE LIABLE FOR ANY DAMAGES WHATSOEVER INCLUDING DIRECT, INDIRECT, INCIDENTAL, CONSEQUENTIAL, LOSS OF BUSINESS PROFITS OR SPECIAL DAMAGES, EVEN IF MICROSOFT CORPORATION OR ITS SUPPLIERS HAVE BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. SOME STATES DO NOT ALLOW THE EXCLUSION OR LIMITATION OF LIABILITY FOR CONSEQUENTIAL OR INCIDENTAL DAMAGES SO THE FOREGOING LIMITATION MAY NOT APPLY.

Last reviewed: February 3, 1998
© 1998 Microsoft Corporation. All rights reserved. Terms of Use.