Ampersands in CommandBarControls

Similar to using ampersands in headers, you have to double them up in the Caption property of CommandBarControls (CBCs). In CBC captions, the ampersand (&) denotes the hotkey for that control. A caption like

&File

will underline the F and make that the hotkey. If you need an ampersand in your caption, use two.

I wrote this procedure to convert captions when I read and write them.

Function HandleAmp(sInput As String, _
    Optional bWrite As Boolean = True) As String

    If bWrite Then
        HandleAmp = Replace97(sInput, “&”, “&&”)
    Else
        HandleAmp = Replace97(sInput, “&&”, “&”)
    End If

End Function

Posted in Uncategorized


Posting code? Use <pre> tags for VBA and <code> tags for inline.

Leave a Reply

Your email address will not be published.