Microsoft KB Archive/255899

= XL97: ActiveX Control Names Change When You Move or Copy Worksheet =

Article ID: 255899

Article Last Modified on 10/11/2006

-

APPLIES TO


 * Microsoft Excel 97 Standard Edition

-



This article was previously published under Q255899



SYMPTOMS
When you use the Move or Copy Sheet command on a worksheet that contains ActiveX controls, the Name property of controls may change.



CAUSE
This problem occurs if you do either of the following before you copy or move the worksheet:
 * You change the name of the controls to a custom name.

-or-


 * You delete one or more controls of the same type.

For specific examples of this problem, see the "More Information" section later in this article.



STATUS
Microsoft has confirmed that this is a problem in the Microsoft products that are listed at the beginning of this article. This problem no longer occurs in Microsoft Excel 2000.



MORE INFORMATION
The Control Toolbox toolbar contains ActiveX controls that you can insert into your worksheet, or into a form in your Microsoft Visual Basic for Applications project. However, when you insert these controls in a worksheet and you then move or copy that sheet, the names of the controls may change.

The following examples illustrate this problem.

User-Defined Names Change to Default Names
 On the View menu, point to Toolbars, and then click Control Toolbox.  On Sheet1, create the following controls, and change the names of the controls to those listed in the following table:

  Control          Name ---         -   TextBox          txtInput ListBox         lstChoice CommandButton   cmdOK To change the name, right-click the control, and then click Properties on the shortcut menu. Type the new name in the (Name) box.

NOTE: You may need to first click the Design Mode button on the Control Toolbox toolbar.  On the Edit menu, click Move or Copy Sheet. In the Move or Copy dialog box, click (new book) in the To book list. Click to select the Create a copy check box, and then click OK.

Notice in the new workbook, the names for the three controls have changed to their defaults of TextBox1, ListBox1, and CommandButton1.

Deleting Controls Reorders Their Names
 On the View menu, point to Toolbars, and then click Control Toolbox.</li>  On Sheet1, create the following controls: <pre class="fixed_text">  Control          Default Name ---            TextBox          TextBox1 TextBox         TextBox2 TextBox         TextBox3 Notice the names of the controls listed in the table above. To view the name, right-click the control, and then click Properties on the shortcut menu. The control's name is shown in the Name box.

NOTE: You may need to first click the Design Mode button on the Control Toolbox toolbar. </li> Delete TextBox1.</li> On the Edit menu, click Move or Copy Sheet. In the Move or Copy dialog box, click (new book) in the To book list. Click to select the Create a copy check box, and then click OK.</li></ol>

Notice that in the new workbook, Excel has reordered and changed the names of the two text box controls to TextBox1 and TextBox2.

<div class="references_section">