PDA

View Full Version : [SOLVED:] Custom Ribbon Add Additional Tab



JT7
01-13-2020, 05:39 PM
I have just started customising my ribbon using Custom UI Editor, however no matter what I try I can not add an additional tab, can someone please provide a script to add another tab to the script I already have as I would like 2 tabs.

For some strange reason it will not allow me to post the code or even upload the .txt example, so if someone could provide me a script that has 2 tabs in it then i will just modify that.

Thanks

Fletcher
01-13-2020, 06:16 PM
You can use VBA's to customize the ribbon, i found this was easier if you are running it on work computers where it seems to slip past the restrictions

Paul_Hossler
01-13-2020, 06:22 PM
Probably just the bold below




<!-- This is example : Add custom tab for Favorite Groups and buttons -->
<!-- *************************************************************************** * -->
<!-- *You can find the Control/groups names in one of the downloads on this page* -->
<!-- ***************http://www.rondebruin.nl/ribbon.htm************************** -->
<!-- *************************************************************************** * -->
<customUI xmlns="http://schemas.microsoft.com/office/2006/01/customui">
<!-- Add Custom tab to the ribbon with your favorite built in groups/controls -->
<!-- The example add three complete groups to the new tab -->
<!-- And create a new group named "Favorite commands" on the new tab -->
<!-- In this group it add four built in controls -->

<ribbon>
<tabs>
<tab id="customTab" label="Favorite Groups" insertAfterMso="TabHome">
<group idMso="GroupClipboard" />
<group idMso="GroupSortFilter" />
<group idMso="GroupInsertIllustrations" />
<group id="YouCustomGroup" label="Favorite commands">
<button idMso="VisualBasic" />
<button idMso="SheetProtect" />
<button idMso="ConvertTextToTable" />
<separator id="MySeparator1" />
<menu idMso="WindowSwitchWindowsMenuExcel" size="large" />
</group>
</tab>
</tabs>
</ribbon>
</

JT7
01-13-2020, 06:37 PM
Thanks, but I use custom images and I haven't found a vba code that allows me to getImage for the buttons.
Also you have provided code for one tab which I do already, however what I wanted was for 2 custom tabs, I am not sure how to add code to get the 2nd custom tab

Paul_Hossler
01-13-2020, 09:23 PM
1. getImage doesn't work for buttons

2. The process is basically the same for 2 tabs

Example with 2 new tabs, each with 2 groups, and each group with 2 buttons




<customUI xmlns="http://schemas.microsoft.com/office/2009/07/customui" onLoad="ribbonstart">
<ribbon>
<tabs>
<tab id="tab2" label="Tab Two" insertAfterMso="TabHome">
<group id="g3" label="Tab2 Group3" >
<button id="b5" label="Button5" size="large" onAction="test" image="Dilbert" />
<button id="b6" label="Button6" size="large" onAction="test" image="Boss" />
</group>


<group id="g4" label="Tab2 Group4" >
<button id="b7" label="Button7" size="large" onAction="test" image="Dilbert" />
<button id="b8" label="Button8" size="large" onAction="test" image="Boss" />
</group>
</tab>


<tab id="tab1" label="Tab One" insertAfterMso="TabHome">
<group id="g1" label="Tab1 Group1" >
<button id="b1" label="Button1" size="large" onAction="test" image="Dilbert" />
<button id="b2" label="Button2" size="large" onAction="test" image="Boss" />
</group>


<group id="g2" label="Tab1 Group2" >
<button id="b3" label="Button3" size="large" onAction="test" image="Dilbert" />
<button id="b4" label="Button4" size="large" onAction="test" image="Boss" />
</group>
</tab>






</tabs>
</ribbon>
</customUI>

JT7
01-13-2020, 09:42 PM
Thank you for your help, much appreciated.
Yes getImage doesn't work with VBA that is why I am using the Custom UI Editor Which then you can add your own pictures, but it still requires some coding also

Paul_Hossler
01-14-2020, 08:34 AM
1. There's a much improved CustomUI editor

https://github.com/fernandreu/office-ribbonx-editor

Are you using that one?


2. In my example, I added two of my own pictures, but the coding only consists of


... image=" ... "

on the <button ... line


3. BTW, there's a dedicated CustomUI forum here, just below the Word forum

JT7
01-14-2020, 04:03 PM
no, I was using the application Custom UI Editor For Microsoft Office.
Curious to how it knew where to get the pictures from as I can't see any pictures in the example workbook and my own have to be in a folder so that it can get them.

Artik
01-14-2020, 04:53 PM
1. getImage doesn't work for buttons
I don't know, maybe I don't understand. Finally, I don't know English. ;)

XML code:
<customUI xmlns="http://schemas.microsoft.com/office/2009/07/customui" onLoad="Rbn_onLoad">
<ribbon >
<tabs >
<tab
id="Tab1"
label="Tab1">
<group
id="Group1"
label="Group1">
<button
id="Button1"
label="Button1"
size="large"
getImage="Button1_getImage"/>
</group >
</tab >
</tabs >
</ribbon >
</customUI >
VBA code:
Option Explicit

Public xRbn As IRibbonUI


Public Sub Button1_getImage(control As IRibbonControl, ByRef returnedVal)
'
' Code for getImage callback. Ribbon control button
'
Dim stPath As String


stPath = "E:\MyFolder\Icons\fingerprint.jpg"

Set returnedVal = LoadPicture(stPath)
End Sub


Public Sub Rbn_onLoad(ribbon As IRibbonUI)
'
' Code for onLoad callback. Ribbon control customUI
'
Set xRbn = ribbon
End Sub

Artik

JT7
01-14-2020, 06:22 PM
I have it all sorted out now, Thanks for all your help Paul and the new xml editor is much better than the earlier version.
Cut my file size down too which is awesome and I don't have to store pictures anymore.

pplanch
10-20-2021, 03:29 AM
Will start a new thread as this one is already marked SOLVED (missed that initially) ...

Very interesting reading. I just started with Office Ribbon Editor to include a custom tab on my ribbon. The idea is to have buttons from various workbooks (later to be converted to add-ins) on the SAME custom tab.

The creation of the tab with the first button group worked fine ... see XML code below :

<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<customUI xmlns=(note this is redacted because the forum apparently denies posts with URL's in them ... it contains the URL to the 2006-01 custom schemas)>
<ribbon>
<tabs>
<tab id="piAddIns" label="pi Add-ins" insertAfterMso="TabHome" >
<group id="piGeneralSettings" label="General Settings" >
<button id="piRegistration" label="Registration" size="large" onAction="UpdateRegistrationSettings" imageMso="AccountSettings" />
<button id="piLanguage" label="Language" size="large" onAction="SelectLanguage" imageMso="MailMergeRecepientsUseOutlookContacts" />
</group>
</tab>
</tabs>
</ribbon>
</customUI>

The problem I have is to then in ANOTHER workbook add XML code that will add that workbook's button to this "new" tab that I just created (called "piAddIns"). I tried XML code below (with variants of id, idQ and idMSO) to no avail. If I could get some help to figure this out (or pointers to what I'm doing wrong), that would be fantastic ...

<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<customUI xmlns= (note this is redacted because the forum apparently denies posts with URL's in them)>
<ribbon>
<tabs>
<tab idQ="piAddIns" label="pi Add-ins" >
<group id="piDatePicker" label="Date Picker" insertAfterQ="piGeneralSettings" >
<button id="piPickDate" label="Pick a Date" size="large" onAction="DatePickerMacro" imageMso="CalendarsGallery" />
</group>
</tab>
</tabs>
</ribbon>
</customUI>