ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Shortcut of menu-item (https://www.excelbanter.com/excel-programming/351930-shortcut-menu-item.html)

Jos Vens[_2_]

Shortcut of menu-item
 
Hi,

I know how to change the text of a menu, and how to assign a procedure, but
I can't assign the shortcut to that item. Here's a part of my procedure
which changes the Print-item of the File menu.

If (vItem.ID = 4) Then
vItem.Caption = "Print mySheet"
vItem.OnAction = "TB_PrintDialog"
vItem.ShortcutText = "Ctrl+P"
End If

The text Ctrl+P is there, but if I press Ctrl+P on my keyboard, the standard
Print-dialog comes in stead of TB_PrintDialog. If I choose the item in the
menu, I get TB_PrintDialog.

Do you have any advise?
Thanks
Jos Vens



Jos Vens[_2_]

Shortcut of menu-item
 
I think I found it:

Application.OnKey "^p", "TB_PrintDialog"

Thanks,
Jos Vens


"Jos Vens" schreef in bericht
...
Hi,

I know how to change the text of a menu, and how to assign a procedure,
but I can't assign the shortcut to that item. Here's a part of my
procedure which changes the Print-item of the File menu.

If (vItem.ID = 4) Then
vItem.Caption = "Print mySheet"
vItem.OnAction = "TB_PrintDialog"
vItem.ShortcutText = "Ctrl+P"
End If

The text Ctrl+P is there, but if I press Ctrl+P on my keyboard, the
standard Print-dialog comes in stead of TB_PrintDialog. If I choose the
item in the menu, I get TB_PrintDialog.

Do you have any advise?
Thanks
Jos Vens




Tom Ogilvy

Shortcut of menu-item
 
If you want to use Ctrl+P to fire your menu item, I believe you would have
to use the Onkey method to assign your onaction macro to the key combination
Ctrl+P.

--
Regards,
Tom Ogilvy


"Jos Vens" wrote in message
...
Hi,

I know how to change the text of a menu, and how to assign a procedure,

but
I can't assign the shortcut to that item. Here's a part of my procedure
which changes the Print-item of the File menu.

If (vItem.ID = 4) Then
vItem.Caption = "Print mySheet"
vItem.OnAction = "TB_PrintDialog"
vItem.ShortcutText = "Ctrl+P"
End If

The text Ctrl+P is there, but if I press Ctrl+P on my keyboard, the

standard
Print-dialog comes in stead of TB_PrintDialog. If I choose the item in the
menu, I get TB_PrintDialog.

Do you have any advise?
Thanks
Jos Vens






All times are GMT +1. The time now is 10:34 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com