Microsoft KB Archive/183472

= XL98: UserControl Property Code Example Doesn't Work =

Article ID: 183472

Article Last Modified on 6/17/2005

-

APPLIES TO


 * Microsoft Excel 98 for Macintosh

-



This article was previously published under Q183472



SYMPTOMS
In Visual Basic for Applications Help in Microsoft Excel 98 Macintosh Edition, the example code that is provided for the UserControl property does not work.



CAUSE
The example code for the UserControl property assumes that the UserControl property applies to Workbook objects; however, the property applies only to the Application object.



WORKAROUND
To work around this behavior, use the examples in the "More Information" section of this article when you want to see an example of the UserControl property.



MORE INFORMATION
In Microsoft Excel 98 Macintosh Edition, you can use the UserControl property to determine whether an instance of Microsoft Excel that is opened through Automation will continue to run when its object is released. By default, the UserControl property has a value of False.

The following examples use the UserControl property in a macro in Visual Basic or Visual Basic for Applications.

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.

Example 1: Leave UserControl Set to False
To use this example, follow these steps:

 In Microsoft Word 98 Macintosh Edition, point to Macro on the Tools menu and click Visual Basic Editor. Or, press OPTION+F11. On the Insert menu, click Module.  Enter the following code: Sub UserControlStaysFalse Set xlApp = CreateObject("Excel.Application.8") xlApp.Visible = True MsgBox "This is Microsoft Excel 98, build " & xlApp.Build xlApp.Quit Set xlApp = Nothing End Sub  On the Tools menu, click Macros. In the list of macros, click UserControlStaysFalse, and then click Run.

The macro runs and displays a message box with the message "This is Microsoft Excel 98, build ." When the macro is finished running, Microsoft Excel is automatically closed.

Example 2: Set UserControl Set to True
To use this example, follow these steps:

 In Microsoft Word 98 Macintosh Edition, point to Macro on the Tools menu and click Visual Basic Editor. Or, press OPTION+F11.</li> On the Insert menu, click Module.</li>  Enter the following code: Sub UserControlSetToTrue Set xlApp = CreateObject("Excel.Application.8") xlApp.Visible = True MsgBox "This is Microsoft Excel 98, build " & xlApp.Build xlApp.UserControl = True Set xlApp = Nothing End Sub </li> On the Tools menu, click Macros. In the list of macros, click UserControlSetToTrue, and then click Run.</li></ol>

The macro runs and displays a message box with the message "This is Microsoft Excel 98, build ." When the macro is finished running, the instance of Microsoft Excel continues to run even though the xlApp object has been released.

Notes About Using the UserControl Property
<ul>  When you set the UserControl property for Microsoft Excel 98 Macintosh Edition to True, you must also set the Visible property to True, for example: xlApp.Visible = True xlApp.UserControl = True If you do not do this, an invisible instance of Microsoft Excel is left running. </li> The UserControl property does not apply to workbooks in Microsoft Excel 98 Macintosh Edition. This property applies only to the Application object itself. Because of this, you generally cannot use the UserControl property in a macro unless it uses Automation (using either CreateObject or GetObject) to control Microsoft Excel 98 from another program (such as Microsoft Word 98 Macintosh Edition).</li> The example of the UserControl property that is included in Visual Basic for Applications Help is incorrect and does not work in Microsoft Excel 98 Macintosh Edition.</li></ul>

Additional query words: XL97 8.0 vbe

Keywords: kbprogramming kbprb KB183472

-

[mailto:TECHNET@MICROSOFT.COM Send feedback to Microsoft]

© Microsoft Corporation. All rights reserved.