Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 2
Default Menu problem

In Sub MenuSetRangeSelectedOption() below, the macro crashes when it
gets to line Set TG1 = MenuItem.Controls("&RangeSelected"). Can
anyone tell m,e what I am doing incortrectly

tia

bob


Option Explicit
Public TG1 As CommandBarButton
Public TG2 As CommandBarButton
Public bMenuRangeSelectedOption As Boolean

Sub Auto_Open()

Dim NewMenu As CommandBarPopup
Dim HelpMenu As CommandBarControl
Dim MenuItem As CommandBarControl
Dim Submenuitem As CommandBarButton

On Error Resume Next
CommandBars(1).Controls("myTools").Delete

' Find the Help Menu
Set HelpMenu = CommandBars(1).FindControl(ID:=30010)

If HelpMenu Is Nothing Then
'Add the menu to the end
Set NewMenu = CommandBars(1).Controls.Add _
(Type:=msoControlPopup, _
temporary:=True)
Else
'Add the menu before Help
Set NewMenu = CommandBars(1).Controls.Add _
(Type:=msoControlPopup, _
Befo=HelpMenu.Index, _
temporary:=True)
End If

' Add a caption for the menu
NewMenu.Caption = "&myTools"

' 8th MENU ITEM
Set MenuItem = NewMenu.Controls.Add _
(Type:=msoControlPopup)
With MenuItem
.Caption = "&Options"
.BeginGroup = True
End With

' 8th MENU ITEM - FIRST SUBMENU ITEM
Set Submenuitem = MenuItem.Controls.Add _
(Type:=msoControlButton)
With Submenuitem
.Caption = "&RangeSelected"
.OnAction = "MenuSetRangeSelectedOption"
End With

bMenuRangeSelectedOption = True
Set TG1 = MenuItem.Controls("&RangeSelected")
TG1.State = msoButtonDown

End Sub


Sub MenuSetRangeSelectedOption()

Set TG1 = MenuItem.Controls("&RangeSelected")
MsgBox TG1
On Error Resume Next
If bMenuRangeSelectedOption = False Then
bMenuRangeSelectedOption = True
TG1.State = msoButtonDown
Else
bMenuRangeSelectedOption = False
TG1.State = msoButtonUp
End If

End Sub
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
worksheet menu bar problem iksuinje Excel Discussion (Misc queries) 2 November 10th 08 08:02 PM
Drop down menu problem kind_joy Excel Worksheet Functions 1 June 14th 08 07:45 AM
Menu access problem Mr. Dob Excel Discussion (Misc queries) 0 June 7th 07 07:35 PM
Excel Menu Problem RONGGGG Excel Discussion (Misc queries) 4 June 13th 05 08:17 PM
Problem with VBE Menu -- Tools References JON-JON Excel Programming 1 September 11th 03 07:20 AM


All times are GMT +1. The time now is 12:20 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"