Adding Accelerator Text to the Menu Caption

C

Cookville

Has anyone had experience with displaying the accelerator (F10 or CTRL+V,
etc) to menu items? All I get is the menu text and the "\a" literal. The
menu displays exactly like it's quoted as if Visio does not see the \a
escape code.

DVS states the following:

Caption specifies the text that appears on a menu or menu item. If you want
to display the accelerator with the menu item, include it as part of the
Caption property's text and insert two spaces between the "\a" and the
accelerator text. For example:
"Open...\a CTRL+O"

In this example, "Open..." is the menu item's caption; "CTRL+O" is the
accelerator text; and "\a" left justifies the accelerator text. Adding the
accelerator text to the Caption property doesn't add an accelerator, it
simply displays it as part of the caption. You add accelerators by using the
accelerator objects in the Visio object model.
 
J

JuneTheSecond

I do not know about accelerator exactly, but if your purpose is only to
display accelerator, it seems "\a" is not needed. I displayed it by "Open...
CTRL+O".
If you need to add accelerator that really works, an idea may be to use add
method to AccelItems collection in AccelTable. You might be able to find
example ciode in visio help doccuments.
 
J

JuneTheSecond

Hera is an example to add accelerator key

Public Sub Add_Accelerator_Key()

Dim vsoUIObject As Visio.UiObject
Dim vsoMenuSets As Visio.MenuSets
Dim vsoMenuSet As Visio.MenuSet
Dim vsoMenus As Visio.Menus
Dim vsoMenu As Visio.Menu
Dim vsoMenuItems As Visio.MenuItems
Dim vsoMenuItem As Visio.MenuItem

Dim vsoAccelTable As Visio.AccelTable
Dim vsoAccelItems As Visio.AccelItems
Dim vsoAccelItem As Visio.AccelItem
Dim intCounter As Integer

Set vsoUIObject = Visio.Application.BuiltInMenus
Set vsoMenuSets = vsoUIObject.MenuSets
Set vsoMenuSet = vsoMenuSets.ItemAtID(visUIObjSetDrawing)
Set vsoMenus = vsoMenuSet.Menus
Set vsoMenu = vsoMenus.AddAt(7)
vsoMenu.Caption = "MyNewMenu(&M)"
Set vsoMenuItems = vsoMenu.MenuItems
Set vsoMenuItem = vsoMenuItems.Add
vsoMenuItem.Caption = "MyNewMenuItem\a Shit+E"
vsoMenuItem.AddOnName = "myMacro"

Set vsoAccelTable = vsoUIObject.AccelTables.ItemAtID(visUIObjSetDrawing)
Set vsoAccelItems = vsoAccelTable.AccelItems
Set vsoAccelItem = vsoAccelItems.Add
With vsoAccelItem
.AddOnArgs = "myMacro"
.Shift = True
.Key = 69
.CmdNum = vsoMenuItem.CmdNum
End With

ThisDocument.SetCustomMenus vsoUIObject
End Sub

Sub myMacro()
MsgBox "TEST"
End Sub

Sub test()
Debug.Print Chr(69)
End Sub
 
C

Cookville

Thanks, but adding accel items is not the issue, just getting the menu
caption to properly display and justify the accel key text.

mel
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top