XL97: "Method 'Delete' of object..." Running Sample Code in Help

Last reviewed: January 7, 1998
Article ID: Q174492
The information in this article applies to:
  • Microsoft Excel 97 for Windows

SYMPTOMS

After you use sample code from the Visual Basic for Applications Help file, you may receive the following error message:

   Run time error '-2147467259(80004005)':
   Method 'Delete' of object 'CommandBar' failed.

CAUSE

This error may occur when the follow conditions are true:

  • You run the following sample code from the CommandBars Property Example window in the Visual Basic for Applications Help file:

          For Each bar In Application.CommandBars
    
              If Not bar.BuiltIn And Not bar.Visible Then bar.Delete
       
          Next
    
       This sample code deletes all custom command bars that aren't visible.
    
        -and-
    
    
  • The Wizard shortcut command bar has not been deleted.

        -or-
    
  • The Small Business Financial Manager add-in is installed.

WORKAROUND

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/supportnet/refguide/default.asp

To workaround this problem, use one of the following methods.

Method 1

Delete the Wizard command bar by running a procedure, and then use the code from the Help file. To remove the command bar, use the following code:

   Sub Remove_Wizard()
   
      Set oToolMenu = CommandBars("Worksheet Menu Bar").Controls("Tools")
      oToolMenu.Controls("Wizard").Delete
   
   End Sub

Method 2

Remove the Wizard command bar by using the Add-Ins dialog box. To do this, follow these steps:

  1. On the Tools menu, click Add-Ins.

  2. Click to clear the Conditional Sum Wizard, File Conversion Wizard, Lookup Wizard, and Web Form Wizard check boxes.

    NOTE: It's possible that not all of these add-ins are selected. These four add-ins are included with Excel. If you installed a new add-in that appears on the Wizard command bar, it may be necessary to remove it.

  3. Click OK.

Method 3

Remove the Small Business Financial Manager add-in. To do this, follow these steps:

  1. On the Tools menu, click Add-Ins.

  2. Click to clear the Small Business Financial Manager check box.

  3. Click OK.

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.

MORE INFORMATION

The procedure in the Help file does not work in Excel because the Wizard shortcut command bar cannot be deleted by using this method.

Restoring the Wizard Command Bar

To restore the Wizard command bar, follow these steps. If you removed the Wizard command bar through the Add-Ins dialog box, skip steps 1 through 3.

  1. On the Tools menu, click Add-Ins.

  2. Click to clear the Conditional Sum Wizard, File Conversion Wizard, Lookup Wizard, and Web Form Wizard check boxes.

  3. Click OK.

  4. On the Tools menu, click Add-Ins.

  5. Click the Conditional Sum Wizard, File Conversion Wizard, Lookup Wizard, and Web Form Wizard check boxes.

  6. Click OK.

REFERENCES

For more information about command bars, click the Office Assistant in the Visual Basic Editor, type "commandbars," click Search, and then click to view "Using command bars."

NOTE: If the Assistant is hidden, click the Office Assistant button on the Standard toolbar. If Visual Basic for Applications Help is not installed on your computer, please see the following article in the Microsoft Knowledge Base:

   ARTICLE-ID: Q120802
   TITLE     : Office: How to Add/Remove a Single Office
               Program or Component


Additional query words: XL97 addins
Keywords : xltoolbar xlui xlwiz kbcode kberrmsg kbprg
Version : WINDOWS:97
Platform : WINDOWS
Issue type : kbbug kbdocerr
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: January 7, 1998
© 1998 Microsoft Corporation. All rights reserved. Terms of Use.