Microsoft KB Archive/151332

= Application.Interactive Value Not Reset When Macro Stops =

Article ID: 151332

Article Last Modified on 10/11/2006

-

APPLIES TO


 * Microsoft Excel 97 Standard Edition
 * Microsoft Excel 95 Standard Edition
 * Microsoft Excel 5.0 Standard Edition
 * Microsoft Excel 98 for Macintosh

-



This article was previously published under Q151332





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
If you forget to reset the property back to true, or encounter an error in the execution of the code, you will likely need to shut down that instance of Microsoft Excel and fix the line of code that caused the error.

To do this, press CTRL+ALT+DELETE in Windows 95/98 or Windows NT and end the Microsoft Excel task.

On the Apple Macintosh, press OPTION+COMMAND+ESCAPE to force Microsoft Excel to quit.

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

Sample Visual Basic Procedure
Microsoft provides programming examples for illustration only, without warranty either expressed or implied. This includes, but is not limited to, the implied warranties of merchantability or fitness for a particular purpose. This article assumes that you are familiar with the programming language that is being demonstrated and with the tools that are used to create and to 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 requirements. If it is necessary to enable user input to Microsoft Excel without restarting the program, you can 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 programs 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 you are 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 program.

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

Windows 3.x and Windows NT

 * 1) Press 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 Start, and then click Run
 * 2) 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 have to click the Finder desktop or another program window in the background to switch to that program.
 * 1) Double-click the hard disk drive and locate the Microsoft Excel icon.
 * 2) Create a copy of the Microsoft Excel icon by holding down OPTION button and dragging the icon to the desktop.
 * 3) Double-click the Microsoft Excel icon.

After starting a separate instance of Microsoft Excel using one of the methods listed earlier, follow these steps:

 On the Insert menu, click Module.  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  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.  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 program. On the Tools menu, point to Macro, and then click Visual Basic Editor.</li> On the Insert menu, click Module.</li>  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 </li> To run the macro, click the insertion point in the macro code, and then press F5.</li></ol>

<div class="status_section">

STATUS
Microsoft has confirmed this to be a problem in the Microsoft products listed at the beginning of this article.

<div class="references_section">