your image

Creating a Toggle Button - MS-Excel Tutorial

sourcedaddy
Related Topic
:- MS Excel

Creating a Toggle Button

A toggle button control is very similar to a check box in that it switches between one of two states: pressed and not pressed. Therefore, as with a check box, you can use it to run a macro that toggles some setting on and off. You create a toggle button by using the <toggleButton> element:

<toggleButton id="value"
label="value"
imageMso="value"
size="normal|large"
InsertAfterMso="value"
InsertBeforeMso="value"
onAction="value"
enabled="true|false"
visible="true|false"
screentip="value"
supertip="value"
keytip="value" />

For example, the following XML code creates a toggle button that, when clicked, runs a macro named ToggleDeveloperTab:

Here's an example:

<toggleButton id="tbToggleDeveloperTab"imageMso="VisualBasic"label="Show Developer Tab"size="large"onAction="Module1.tbToggleDeveloperTab_OnAction" />

Here's the tbToggleDeveloperTab_OnAction macro:

Sub tbToggleDeveloperTab_OnAction(ByVal control As IRibbonControl, pressed As Boolean)Options.ShowDevTools = pressedEnd Sub

When your toggle button (or check box) alters an application setting, the control's initial state should reflect the current value of the setting.

As with the <checkBox> element, the Sub statement for the <toggleButton> element includes a Boolean variable named pressed that passes the current state of the toggle button.

 

Comments