Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 441
Default Add "BeginGroup" to customized shortcut menus

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   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1,080
Default Add "BeginGroup" to customized shortcut menus

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
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Shortcut to switch from "fill down" to "copy" with mouse drag RJ Dake Excel Discussion (Misc queries) 3 August 13th 09 05:35 PM
Excel - Golf - how to display "-2" as "2 Under" or "4"as "+4" or "4 Over" in a calculation cell Steve Kay Excel Discussion (Misc queries) 2 August 8th 08 01:54 AM
keyboard shortcut to return to previous cell after "find" or "got. Nadavb New Users to Excel 1 May 25th 08 01:39 AM
Shortcut key for "Paste Options" and "Error Checking" buttons? johndog Excel Discussion (Misc queries) 1 October 6th 06 11:56 AM
save and restore "Workbook Menu Bar" & "Cell" menus Jeff Higgins Excel Programming 2 February 14th 05 01:33 AM


All times are GMT +1. The time now is 02:13 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Copyright ©2004-2025 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"