umarpervaiz425
New Member
- Joined
- Nov 25, 2023
- Messages
- 2
- Office Version
- 365
- Platform
- Windows
This is my requirement:
I have an xlsm file which has two tabs in the ribbon. The tabs are names as, GENERAL and GTH. There are two buttons inside GENERAL tab named "Inocio" and "Configuration". And there are two buttons inside GTH named as "Resumen" and "Detalldo". I want to make an add-in function for my file so that whenever I click on any of those four buttons inside the tabs, The effect should activate when you press on an icon and return to its original icon when you move to another. The effect should change the icon image to backup.png when clicked and return to its original image when you move to another icon.
Note: I am using RibbonX xml.
Here is my XML code:
And here is my VBA code:
Attached are the images which would be useful to understand my requirement:
I have an xlsm file which has two tabs in the ribbon. The tabs are names as, GENERAL and GTH. There are two buttons inside GENERAL tab named "Inocio" and "Configuration". And there are two buttons inside GTH named as "Resumen" and "Detalldo". I want to make an add-in function for my file so that whenever I click on any of those four buttons inside the tabs, The effect should activate when you press on an icon and return to its original icon when you move to another. The effect should change the icon image to backup.png when clicked and return to its original image when you move to another icon.
Note: I am using RibbonX xml.
Here is my XML code:
XML:
<customUI xmlns="http://schemas.microsoft.com/office/2009/07/customui">
<!-- Disable Share in the Ribbon of Excel 2016. -->
<commands>
<command idMso="Collaborate" enabled="false" />
</commands>
<ribbon startFromScratch="true">
<tabs>
<tab id="Tab1" label="GENERAL" >
<group id="customGroup1" label="Home">
<splitButton id="mySplitButton1" size="large">
<button id="customButton1" image="inicio.png" label="Inicio" supertip="Presionar" onAction="Macro1"/>
<menu id="splitMenu1" itemSize="normal">
<!-- use itemSize = large or use normal -->
<button id="customButton2" label="Hola" onAction="Macro2" image="registrarse.png" />
</menu>
</splitButton>
<separator id="MySeparator1" />
<button id="customButton3" label="Configuracion" size="large" onAction="Macro3" image="configuracion.png" />
</group>
</tab
<tab id="Tab2" label="GTH" >
<group id="customGroup5" label="Ficha Financiera">
<splitButton id="mySplitButton2" size="large">
<button id="customButton4" image="resumen.png" label="Resumen" supertip="Presionar" onAction="Macro4"/>
<menu id="splitMenu2" itemSize="normal">
<!-- use itemSize = large or use normal -->
<button id="customButton5" label="Examinar" onAction="Macro5" image="importar.png" />
</menu>
</splitButton>
<separator id="MySeparator7" />
<button id="customButton6" label="Detallado" size="large" onAction="Macro6" image="detallado.png" />
<splitButton id="mySplitButton60" size="large">
</splitButton>
</group>
</tab>
</tabs>
</ribbon>
</customUI>
<!-- Macros UI -->
And here is my VBA code:
VBA Code:
Option Private Module
Option Explicit
'----------------------GENERAL--------------------------------
'-------Home-------
Sub Macro1(control As IRibbonControl)
ThisWorkbook.Sheets("Inicio").Activate
End Sub
Sub Macro2(control As IRibbonControl)
Call hola
End Sub
Sub Macro3(control As IRibbonControl)
ThisWorkbook.Sheets("Configuración").Activate
End Sub
'----------------------GTH--------------------------------
'-------Ficha Financiera-------
Sub Macro4(control As IRibbonControl)
ThisWorkbook.Sheets("Resumen").Activate
End Sub
Sub Macro5(control As IRibbonControl)
Call Examinar
End Sub
Sub Macro6(control As IRibbonControl)
ThisWorkbook.Sheets("Detallado").Activate
End Sub
Attached are the images which would be useful to understand my requirement: