ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Problem getting a msoButtonDown status (https://www.excelbanter.com/excel-programming/282707-problem-getting-msobuttondown-status.html)

[email protected]

Problem getting a msoButtonDown status
 
'
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, _
Befo=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



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

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