XML Ribbon toggleButton

D4rwin

Board Regular
Joined
Mar 31, 2014
Messages
91
I'm very new to the world of XML ribbon customization so I'm wondering if someone can help me with what I'm trying to achieve. I have a macro which allows a user to select any cell y rows and x columns away from the active cell and have it "follow" the movements of the activecell. I'm trying to build a toggle button which will run the macro with myTog=True (on), and when pressed again it will run the macro again and set myTog = False. So, my question is how I interact with the ribbon toggle button in the macro code to manipulate myTog.
Any suggestions?

Here's my XML code:
<togglebutton id="Tracker" label="Track Cells" screentip="Track Cells" supertip="Select a cell to track" image="TRACK1" size="large"><togglebutton id="Tracker" label="Track Cells" screentip="Track Cells" supertip="Select a cell to track" image="TRACK1" size="large">
HTML:
<toggleButton id="Tracker" label="Track Cells" screentip="Track Cells" supertip="Select a cell to track" image="TRACK1" size="large"/>
<togglebutton id="Tracker" label="Track Cells" screentip="Track Cells" supertip="Select a cell to track" image="TRACK1" size="large">

Here's my macro code:
Code:
    If myTog = False Then Exit Sub
    Union(ActiveCell, ActiveCell.Offset(Track_Y, Track_X)).Select
</togglebutton></togglebutton></togglebutton></togglebutton>
 
Last edited:

Excel Facts

Excel Can Read to You
Customize Quick Access Toolbar. From All Commands, add Speak Cells or Speak Cells on Enter to QAT. Select cells. Press Speak Cells.
Ok thanks.
The GetPressed now calls another module which prompts a user for input. However, if the user clicks "cancel", how do I turn the toggle off?
 
Upvote 0
If the getPressed callback sets the return value to True, it will be pressed; if False, it won't be.
 
Upvote 0
What am I doing wrong here? "Pressed" is giving me false in myTogTest

I would like for myTogTest to run when "pressed" is True, but if False myTogTest calls GetPressed and turns the toggle off.

Code:
Public pressed As Boolean

Sub GetPressed(control As IRibbonControl, pressed As Boolean)    

Call myTogTest

End Sub


Sub myTogTest()

    If pressed = True Then
        MsgBox "Toggle: ON"
    Else
        MsgBox "Toggle: OFF"
    End If

End Sub
 
Upvote 0

Forum statistics

Threads
1,216,125
Messages
6,128,998
Members
449,480
Latest member
yesitisasport

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top