XL5: ToolbarButtons.Add Doesn't Add Status Bar Text to Button

ID: Q119379

5.00 WINDOWS kbprg

The information in this article applies to:

SYMPTOMS

In Microsoft Excel, if you use the Add method of the ToolbarButtons object in a Visual Basic procedure, to both add a button to a toolbar and to assign a macro to the button, the macro status bar text is not added to the button.

CAUSE

This behavior occurs if you add the button to the toolbar and assign the macro to the button using one line in the procedure, as in the following example:

   Toolbars(1).ToolbarButtons.Add Button:=208, Before:=1, OnAction:="OK"

When you use the OnAction argument along with the other named arguments of the Add method, the status bar text for the macro that you assign to the button is not added to the button. Instead, the default status bar text for the button that you assign to the toolbar is displayed in the status bar when you either choose the button or place the mouse pointer over the button.

WORKAROUNDS

To avoid this behavior, use one line in the procedure to add the button to the toolbar, and use a separate line in the procedure to assign the macro to the button. The following is an example of this method:

Microsoft provides examples of Visual Basic procedures 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 Visual Basic procedure is provided 'as is' and Microsoft does not guarantee that it can be used in all situations. Microsoft does not support modifications of this procedure to suit customer requirements for a particular purpose.

   Sub Add_Button()
      Toolbars(1).ToolbarButtons.Add Button:=208, Before:=1
      Toolbars(1).ToolbarButtons(1).OnAction = "Macro1"
   End Sub

   -or-

  • To correct this problem, do the following:

    1. From the Tools menu, choose Macro.

    2. From the Macro Name/Reference list, select the macro that is assigned

          to the button.
    

    3. Choose the Options button, and then choose OK (you don't have to make

          any changes).
    

    4. Close the Macro dialog box.

    STATUS

    Microsoft has confirmed this to be a problem in the Microsoft products listed at the beginning of this article. This problem was corrected in Microsoft Excel version 5.0c.

    MORE INFORMATION

    For additional information, see the following article(s) in the Microsoft Knowledge Base:

       ARTICLE-ID: Q112632
       TITLE     : Setting Status Bar Text and ToolTips for Toolbar Buttons
    
    

    REFERENCES

    For more information about the OnAction Property, choose the Search button in the Visual Basic Reference and type:

        OnAction Property
    
    
    KBCategory: kbprg KBSubcategory:

    Additional reference words: 5.00 incorrect wrong

    Keywords          : kbprg
    Version           : 5.00
    Platform          : WINDOWS

    Last Reviewed: June 2, 1998