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:

Some videos you may like

Excel Facts

Highlight Duplicates
Home, Conditional Formatting, Highlight Cells, Duplicate records, OK to add pink formatting to any duplicates in selected range.

rtpud

New Member
Joined
Jul 15, 2010
Messages
9
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
 

FryGirl

Well-known Member
Joined
Nov 11, 2008
Messages
1,189
Office Version
  1. 2016
Platform
  1. Windows
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.
 

rtpud

New Member
Joined
Jul 15, 2010
Messages
9
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:

RoryA

MrExcel MVP, Moderator
Joined
May 2, 2008
Messages
35,517
Office Version
  1. 365
  2. 2019
  3. 2016
  4. 2010
Platform
  1. Windows
  2. MacOS

ADVERTISEMENT

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

Sub PGCE_Reps(control As IRibbonControl, pressed As Boolean)

 

rtpud

New Member
Joined
Jul 15, 2010
Messages
9
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:

RoryA

MrExcel MVP, Moderator
Joined
May 2, 2008
Messages
35,517
Office Version
  1. 365
  2. 2019
  3. 2016
  4. 2010
Platform
  1. Windows
  2. MacOS
That's what the boolean is for:
Code:
If pressed then
   macro1
else
   macro2
end if

:)
 

Watch MrExcel Video

Forum statistics

Threads
1,109,351
Messages
5,528,194
Members
409,807
Latest member
nicky736

This Week's Hot Topics

  • Change military grades into rank
    Afternoon all Need help with formula that will change military rank (i.e. 1, 2, 3 into Amn, A1C, SrA). Running IF formula that does not work...
  • VBA COUNTIF SOLUTION
    Hi The following are the errors spread across the several columns from E to Q ie. 13 columns across several sheets with more than 500 rows per...
  • INSERT ROW WITH SPECIFIS TEXT IN A COLUMN
    Hi All! How can identify that that the row to be inserted has to be inserted before 1st row with specific text in column F. If I record the...
  • Auto-Create a monthly Sign in sheet for preschool students
    The image below is what each page looks like. Above is space for the "Child Name" "Month" "Class" School days are obviously Monday-Friday but...
  • VBA vlookup multiple results
    Hi folks, Hopefully someone out there can help. I have a list to vlookup which works (ish). the lookup only picks up the first instance of the...
  • Extract values for earliest/latest times
    I am trying to put together a formula to get the earliest start time, the latest end time from column A for each person in Column B-F without the...
Top