PDA

View Full Version : Solved: How to add an Accelerator to a Caption?



RonMcK3
09-11-2007, 08:48 PM
Hi, All !

In Import notepad and wordpad text files, Johnske uses the following code in the ThisWorkbook module to add a program and its caption to the Right Click menu.

My question: Is it at all practicable to assign an Accelerator for this menu caption, like those on the other menu options? (Assuming of course that I find a letter not already in use on the rt-clk menu.) : pray2::help:dunno

Private Sub Workbook_Open()

'//remove any previous right-click controls
Run "RemoveFromMenu"

'//now add new right-click controls
With Application.CommandBars("Cell")
.Controls.Add(Type:=msoControlButton). _
Caption = "My Caption Goes Here"

'//assign procedures to these controls
.Controls("Import Account Data"). _
OnAction = "MyProgramNameGoesHere"

End With

End Sub

Thanks in advance!

TonyJollans
09-12-2007, 12:06 AM
Just put an ampersand before the character in the caption you want to use as the accelerator key ...


Private Sub Workbook_Open()

'//remove any previous right-click controls
Run "RemoveFromMenu"

'//now add new right-click controls
With Application.CommandBars("Cell")
.Controls.Add(Type:=msoControlButton). _
Caption = "M&y Caption Goes Here"

'//assign procedures to these controls
.Controls("Import Account Data"). _
OnAction = "MyProgramNameGoesHere"

End With

End Sub

RonMcK3
09-12-2007, 04:42 AM
Just put an ampersand before the character in the caption you want to use as the accelerator key ...


Private Sub Workbook_Open()

'//remove any previous right-click controls
Run "RemoveFromMenu"

'//now add new right-click controls
With Application.CommandBars("Cell")
.Controls.Add(Type:=msoControlButton). _
Caption = "M&y Caption Goes Here"

'//assign procedures to these controls
.Controls("Import Account Data"). _
OnAction = "MyProgramNameGoesHere"

End With

End Sub



Tony,

Thank you very much.

:thumb