Home |
Search |
Today's Posts |
|
#1
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
I am using Office 2003 on Windows XP. The following function adds two custom
button controls to the top of every shortcut menu. This runs using an "OnActivate" event and runs great. Except for one small but annoying thing. I want a "BeginGroup" line to separate my custom items from the rest of the built-in menu choices. But, when I enter a line of code to include this, it errors out. This line is noted below and also included below for your convenience is a function to reset your shortcut menus to normal. Can someone please correct my code so it will work right? Public Function ShortCutMenuModify() Dim cbBar As CommandBar Dim lX As Long For lX = 1 To Application.CommandBars.Count If CommandBars(lX).Type = msoBarTypePopup And CommandBars(lX).BuiltIn = True Then Set cbBar = Application.CommandBars(lX) With cbBar .Controls.Add Type:=msoControlButton, Befo=1 .Controls(1).Caption = "GOTO" .Controls(1).FaceId = 5828 .Controls(1).OnAction = "RunFOREIGN" .Controls.Add Type:=msoControlButton, Befo=1 .Controls(1).Caption = "PRINT" .Controls(1).FaceId = 5828 .Controls(1).OnAction = "RunFOREIGN" 'THE FOLLOWING LINE CAUSES AN ERROR, WHY? - HOW FIX? If .Controls.Count 4 Then .Controls(3).BeginGroup = True End With End If Next lX End Function RUN THE FOLLOWING TO RESET ALL MENUS (This runs fine but is included for your convenience): Public Function ShortCutMenuReset() 'RESET EXCEL'S BUILT-IN RIGHT-CLICK SHORTCUT MENU: CALLED ON WORKBOOK DEACTIVATE Dim cmdBar As CommandBar Dim lngX As Long For lngX = 1 To Application.CommandBars.Count If CommandBars(lngX).Type = msoBarTypePopup And CommandBars(lngX).BuiltIn = True Then CommandBars(lngX).Reset Next lngX End Function |
#2
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
Works for me. What is the error message?
-- Vasant "quartz" wrote in message ... I am using Office 2003 on Windows XP. The following function adds two custom button controls to the top of every shortcut menu. This runs using an "OnActivate" event and runs great. Except for one small but annoying thing. I want a "BeginGroup" line to separate my custom items from the rest of the built-in menu choices. But, when I enter a line of code to include this, it errors out. This line is noted below and also included below for your convenience is a function to reset your shortcut menus to normal. Can someone please correct my code so it will work right? Public Function ShortCutMenuModify() Dim cbBar As CommandBar Dim lX As Long For lX = 1 To Application.CommandBars.Count If CommandBars(lX).Type = msoBarTypePopup And CommandBars(lX).BuiltIn = True Then Set cbBar = Application.CommandBars(lX) With cbBar .Controls.Add Type:=msoControlButton, Befo=1 .Controls(1).Caption = "GOTO" .Controls(1).FaceId = 5828 .Controls(1).OnAction = "RunFOREIGN" .Controls.Add Type:=msoControlButton, Befo=1 .Controls(1).Caption = "PRINT" .Controls(1).FaceId = 5828 .Controls(1).OnAction = "RunFOREIGN" 'THE FOLLOWING LINE CAUSES AN ERROR, WHY? - HOW FIX? If .Controls.Count 4 Then .Controls(3).BeginGroup = True End With End If Next lX End Function RUN THE FOLLOWING TO RESET ALL MENUS (This runs fine but is included for your convenience): Public Function ShortCutMenuReset() 'RESET EXCEL'S BUILT-IN RIGHT-CLICK SHORTCUT MENU: CALLED ON WORKBOOK DEACTIVATE Dim cmdBar As CommandBar Dim lngX As Long For lngX = 1 To Application.CommandBars.Count If CommandBars(lngX).Type = msoBarTypePopup And CommandBars(lngX).BuiltIn = True Then CommandBars(lngX).Reset Next lngX End Function |
Reply |
Thread Tools | Search this Thread |
Display Modes | |
|
|
![]() |
||||
Thread | Forum | |||
Shortcut to switch from "fill down" to "copy" with mouse drag | Excel Discussion (Misc queries) | |||
Excel - Golf - how to display "-2" as "2 Under" or "4"as "+4" or "4 Over" in a calculation cell | Excel Discussion (Misc queries) | |||
keyboard shortcut to return to previous cell after "find" or "got. | New Users to Excel | |||
Shortcut key for "Paste Options" and "Error Checking" buttons? | Excel Discussion (Misc queries) | |||
save and restore "Workbook Menu Bar" & "Cell" menus | Excel Programming |