Answered by:
Custom Ribbon in Excel

Question
-
Hi,
I have a VSTO add-in and have provided a Ribbon interface for the operations available through this add-in. I have tried using both the CustomUI Editor and the Visual Studio's Ribbon designer, but in both cases I could only create Groups that look like the 'Clipboard' group in the Home Tab of Excel. (That is either 1 large button or 3 small buttons in a column.)
How can I add groups that look like the 'Font' and 'Alignment' groups of the Home Tab? Is it possible to create such groups (having only 2 buttons/rows in each column) in a custom tab?
Regards,
CSThursday, November 29, 2012 10:29 AM
Answers
-
Hi CS,
Thank you for posting in the MSDN Forum.
You can try the below code.
<tab id="DemoTab" label="Demo" insertBeforeMso="TabHome"> <group id="DemoGroup" label="Demo Group"> <button id="button1" imageMso="HappyFace" label="Button 1"/> <button id="button2" imageMso="HappyFace" label="Button 2"/> <labelControl id="label1" label=" "/> <button id="button3" imageMso="HappyFace" label="Button 3"/> <button id="button4" imageMso="HappyFace" label="Button 4"/> <labelControl id="label2" label=" "/> </group> </tab>
Hope it helps.
Best regards,
Quist Zhang [MSFT]
MSDN Community Support | Feedback to us
- Proposed as answer by Asadulla JavedEditor Friday, November 30, 2012 11:11 AM
- Marked as answer by Quist Zhang Tuesday, December 4, 2012 6:09 AM
Friday, November 30, 2012 5:22 AM -
Hi CS,
As far as I'm concerned, that cannot be achieved. You can refer to the answer of this thread.
You can add a separator to make the 4 buttons divided into 2 columns however they will be top aligned still.
Regards,
Quist Zhang [MSFT]
MSDN Community Support | Feedback to us
Develop and promote your apps in Windows Store
Please remember to mark the replies as answers if they help and unmark them if they provide no help.- Marked as answer by Quist Zhang Tuesday, December 4, 2012 6:09 AM
Tuesday, December 4, 2012 6:08 AM
All replies
-
Have a look at the buttonGroup control.Thursday, November 29, 2012 1:35 PM
-
This is, of course, possible. I recommend you get a copy of Robert Martin, Ken Puls, and Teresa Hennig's book "RibbonX - Customizing the Office 2007 Ribbon" They actually show you how to do exactly this in one of the examples in the book. You might be able to find a chapter or two online.
HTH,
Eric
Tu ne cede malis sed contra audentior ito.
Explicit hoc totum,
Pro Christo da mihi potum.Thursday, November 29, 2012 1:37 PM -
Hi guys,
Thanks for your suggestions, but it seems that I put the question properly.
Consider the following XML for adding some controls in Ribbon.
<customUI xmlns="http://schemas.microsoft.com/office/2006/01/customui"> <ribbon> <tabs> <tab id="DemoTab" label="Demo" insertBeforeMso="TabHome"> <group id="DemoGroup" label="Demo Group"> <button id="button1" imageMso="HappyFace" label="Button 1"/> <button id="button2" imageMso="HappyFace" label="Button 2"/> <button id="button3" imageMso="HappyFace" label="Button 3"/> <button id="button4" imageMso="HappyFace" label="Button 4"/> </group> </tab> </tabs> </ribbon> </customUI>
On adding the above XML to a workbook/document, they are placed in the Ribbon as seen in the image below
Here the first 3 buttons are placed in the first column of the Demo Group. This looks clumsy when I add many more controls in the same tab. ButtonGroup control also has the same behavior.
I want to know whether I can make the same set of buttons look like this
I hope this makes the question more clear.
Regards,
CSFriday, November 30, 2012 4:52 AM -
Hi CS,
Thank you for posting in the MSDN Forum.
You can try the below code.
<tab id="DemoTab" label="Demo" insertBeforeMso="TabHome"> <group id="DemoGroup" label="Demo Group"> <button id="button1" imageMso="HappyFace" label="Button 1"/> <button id="button2" imageMso="HappyFace" label="Button 2"/> <labelControl id="label1" label=" "/> <button id="button3" imageMso="HappyFace" label="Button 3"/> <button id="button4" imageMso="HappyFace" label="Button 4"/> <labelControl id="label2" label=" "/> </group> </tab>
Hope it helps.
Best regards,
Quist Zhang [MSFT]
MSDN Community Support | Feedback to us
- Proposed as answer by Asadulla JavedEditor Friday, November 30, 2012 11:11 AM
- Marked as answer by Quist Zhang Tuesday, December 4, 2012 6:09 AM
Friday, November 30, 2012 5:22 AM -
Thanks Quist,
What you suggest would result in having the buttons top aligned, with the third position vacant. I tried this earlier, but the results were not good enough. I would like to place the buttons just like the 'Wrap Text' and 'Merge & Center' buttons in the Alignment group of the Home tab, evenly distributed in the available space.
Regards,
CS- Edited by C_S Sunday, December 2, 2012 11:36 AM
Sunday, December 2, 2012 11:35 AM -
Why not try to make Buttons 3 and 4 with no image, and a label of " " ?
This ribbon formatting is really tricky and requires some creative thinking.
BTW: Doe anyone know the differences between Group and ButtonGroup ribbon objects ?
- Edited by Syswizard Monday, December 3, 2012 4:42 PM
Monday, December 3, 2012 4:25 PM -
Hi CS,
As far as I'm concerned, that cannot be achieved. You can refer to the answer of this thread.
You can add a separator to make the 4 buttons divided into 2 columns however they will be top aligned still.
Regards,
Quist Zhang [MSFT]
MSDN Community Support | Feedback to us
Develop and promote your apps in Windows Store
Please remember to mark the replies as answers if they help and unmark them if they provide no help.- Marked as answer by Quist Zhang Tuesday, December 4, 2012 6:09 AM
Tuesday, December 4, 2012 6:08 AM -
BTW: Does anyone know the differences between Group and ButtonGroup ribbon objects ?
Referring to the Home tab Clipboard, Font, Alignment etc are all Groups.
There are several examples of ButtonGroup in each of the groups Font, Alignment & Number. Eg, the set of Bold, Italic & Underline are all buttons (without labels) in a ButtonGroup.
It ought to be possible to vertically space two rows of buttons equally between the allocated height of three rows, but if Cindy says it isn't I guess it's not!
Peter Thornton
Tuesday, December 4, 2012 4:22 PM