XL: Setting Status Bar Text and ToolTips for Toolbar Buttons

ID: Q112632

The information in this article applies to:

SUMMARY

In Microsoft Excel versions 5.0 and later, you can assign status bar text to a toolbar button by using a Microsoft Visual Basic for Applications procedure or by using the Status Bar Text box in the Macro Options dialog box.

NOTE: To display the Macro Options dialog box, click Macro on the Tools menu, select the name of the macro assigned to the toolbar button, and click the Options button.

ToolTips is a new feature in Microsoft Excel starting with version 5.0. ToolTips can only be assigned to a toolbar button by using a macro.

The following information describes how you can set the status bar text and ToolTip for a toolbar button and provides examples.

MORE INFORMATION

Status Bar Text

The text that is displayed on the status bar when you choose a button on a toolbar is a property of the macro assigned to the button you choose, not a property of the button itself. When you assign a macro to a toolbar button, the status bar text for that macro is assigned to the corresponding toolbar button and is displayed when you position the mouse cursor over that toolbar button.

NOTE: This mouse pointer behavior differs from earlier versions of Microsoft Excel. In earlier versions you have to hold down the left mouse button while the pointer is on top of the toolbar button in order to read the status bar text.

The status bar text changes whenever a macro is assigned to a toolbar button. If a macro that you assign to a toolbar button does not have status bar text, the text displayed on the status bar when you choose that button is the default text for that toolbar button. For example, if you assign a macro to a button taken from the Custom category, and you do not add a Status Bar Text entry for this macro, the default text displayed on the status bar for this button is "Creates A Button To Which You Can Assign A Macro."

ToolTips

A ToolTip is a property of the individual toolbar button. The only way to change a ToolTip for a button is by using a Visual Basic macro to explicitly set the Name property for a particular toolbar button.

VISUAL BASIC MACRO EXAMPLES

The following examples demonstrate how to change the ToolTip name for buttons on a toolbar (Macro to Change ToolTip Names for Buttons on Toolbar) and how to add a button to a toolbar and then assign a ToolTip, macro, and status bar text to that button (Macro to Create and Customize Toolbar and Buttons).

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 professionals 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/support/supportnet/refguide/

Macro to Change ToolTip Names for Buttons on Toolbar

When you create a custom toolbar button in Microsoft Excel, the default ToolTip that is created for that button is named "Custom." The only way to change this ToolTip is by using a Visual Basic macro. The following is an example of how you can accomplish this:

   Sub ChangeTooltips()

      Set mytoolbar = Toolbars("standard")

      For Each mytool In mytoolbar.ToolbarButtons

         Message = "Enter a new tooltip name"   ' Set prompt.
         Title = "Tooltip changer" ' Set title.
         Default = mytool.Name   ' Set default.

         ' If tool is not a gap, display input box.
         If Not mytool.IsGap Then
            MyValue = InputBox(Message, Title, Default)

            ' Change tooltip name.
            mytool.Name = MyValue

         End If

      Next

   End Sub

NOTES:

Macro to Create and Customize Toolbar and Buttons

The following Visual Basic macro example does the following:

NOTES:

REFERENCES

"Visual Basic User's Guide," version 5.0, Chapter 12, "Managing Toolbars and Toolbar Buttons with Visual Basic"

For more information about toolbar buttons, choose the Search button in Help and type:

    toolbar buttons

Additional query words: tool tip tips vba
Keywords          : kbcode kbprg kbdta EPUCon PgmOthr KbVBA 
Version           : WINDOWS: 5.0, 5.0c, 7.0; MACINTOSH: 5.0, 5.0a
Platform          : MACINTOSH WINDOWS
Issue type        : kbhowto

Last Reviewed: May 17, 1999