Trouble with checkbox in Ribbon

rtpud

New Member
Joined
Jul 15, 2010
Messages
9
Hi All,
Having an issue and cannot seem to trace the mistake, because I have kept everything as basic as possible so far...
I have added a tab to the ribbon in excel with the following XML code (I have removed all the "<" as even in the CODE structure, it does not display correctly:
<customui xmlns="http://schemas.microsoft.com/office/2006/01/customui"><customui xmlns="http://schemas.microsoft.com/office/2006/01/customui">customUI xmlns="http://schemas.microsoft.com/office/2006/01/customui">
ribbon>
tabs>
tab id="CustomTab" label="PGCE Projects">
group id="SampleGroup" label="Groupings Displayed">
checkBox id="CheckBox1" label="PGCE Reps"
screentip="Hides/Unhides PGCE Reps for the Project"
onAction="PGCE_Reps" />
/group>
/tab>
/tabs>
/ribbon>
/customUI>

The display of the tab and the checkbox and all the labels appears fine.
I have written the following demo macro:

Code:
Sub PGCE_Reps()
    Columns("R:Z").Hidden = True
End Sub
The macro also runs fine from the Macros menu.

However, when I click the check-box on the ribbon I get this: "Wrong number of arguments or invalid property assignment".

Anyone know whats wrong here?
The eventual goal is to have Macro A execute once when the checkbox is checked, and Macro B execute once when the checkbox is unchecked to basically hide and unhide a grouping of columns based on a description.

Thanks in advance</customui></customui>
 
Last edited:

Excel Facts

Select a hidden cell
Somehide hide payroll data in column G? Press F5. Type G1. Enter. Look in formula bar while you arrow down through G.
Bring
Up
My
Post


I read the rules and said it was OK to bump a few times per day, I figured that meant this was OK...plz PM me if there is a minimum wait time to bump.
tx
 
Upvote 0
My suggestion, put those "<" back in.

The RibbonX is very sensitive and one character out of place will ruin it all.

Also, another suggestion, go to Change the Ribbon in Excel 2007 or Excel 2010 where you will find the correct syntax along with examples to download.

Not quite what I meant. I took out the "<" for posting the code on this message board. in the XML file, they are there.

Also, that is exactly where I started for doing this...hence the confusion as to why the error...
 
Last edited:
Upvote 0
The declaration for your callback is incorrect - it needs to be:
Rich (BB code):

Sub PGCE_Reps(control As IRibbonControl, pressed As Boolean)

 
Upvote 0
The declaration for your callback is incorrect - it needs to be:
Rich (BB code):

Sub PGCE_Reps(control As IRibbonControl, pressed As Boolean)



Thanks! I did get the (control As IRibbonControl) in there, but still forgot the boolean piece!

Now for the second part, I have no clue how to reference a boolean control that is contained within the IRibbon. Do I reference it as the ID given within the XML code? I am searching the forums now, but since I have someone actively here, figured it couldn't hurt to ask.
basically, to ge thte code such that on True, run Macro1, on False, Run Macro 2.
 
Last edited:
Upvote 0
That's what the boolean is for:
Code:
If pressed then
   macro1
else
   macro2
end if

:)
 
Upvote 0

Forum statistics

Threads
1,213,557
Messages
6,114,288
Members
448,563
Latest member
MushtaqAli

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