Problem getting a msoButtonDown status

P

peterF

'
How can I tell is a button on a menu item is checked?

I am using this code

If (TG8.State = msoButtonDown) Then
bMenuAllWorksheetsOption = True
End If

however even if the button is not checked, the If statement indicates
that it is.

tia


Private TG1 As CommandBarButton

Sub Auto_Open()

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, _
Before:=HelpMenu.Index, _
temporary:=True)
End If

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

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

' OPTIONS MENU ITEM - FIRST SUBMENU ITEM
Set Submenuitem = MenuItem.Controls.Add _
(Type:=msoControlButton)
With Submenuitem
.Caption = "OPTIONS MESSAGES: Show &Range Selected"
.OnAction = "MenuSetRangeSelectedOption"
End With

bMenuActiveWorksheetOption = True
Set TG1= MenuItem.Controls("OPTIONS RANGE: Use SELECTED
W&orksheet")
TG1State = msoButtonDown
'MsgBox "TG7 " & MenuItem.Controls("OPTIONS RANGE: Use SELECTED
W&orksheet").ID


End Sub

Sub CheckButtonAndBooleanStatus()


On Error Resume Next
If (TG8.State = msoButtonDown) Then
bMenuAllWorksheetsOption = True
End If

End Sub
 

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