Ceci est une page optimisée pour les mobiles. Cliquez sur ce texte pour afficher la vraie page.

Microsoft 365 Création d'un nouvel onglet du ruban en vba et y attacher 4 macros complémentaires (MAC et PC)

RyuAutodidacte

XLDnaute Impliqué
Bonjour,

j'ai beau chercher partout mais je ne trouve de solution pour le moment …

Comme l'onglet "Acceuil" qui existe dans le ruban, je cherche à pourvoir créer par vba un nouvel onglet "TOTO" et y insérer 4 macros, provenant d'un complément Excel d'un fichier xlam déjà insérer par macro :
VB:
Sub Add_AddIn() 'version Mac (peut être PC aussi pouvez vous confirmer SVP)
Dim addInPath As String
    addInPath = "MonChemin/TEST.xlam"
    AddIns.Add addInPath
    AddIns("TEST").Installed = True '
End Sub
Le but est de pourvoir faire une automatisation d'installation sur plusieurs utilisateurs Mac et PC

merci d'avance pour vos réponses

Ryu
 

RyuAutodidacte

XLDnaute Impliqué

patricktoulon

XLDnaute Barbatruc
a ben maintenant je les integre directement dans le fichier xl
avant avec la version 2020 oui je mettais les callback dans un fichier txt
et je copiais du fichier dans un module

alors le xml du switchGroup
XML:
<?xml version="1.0" encoding="utf-8" standalone="yes"?>
<customUI xmlns="http://schemas.microsoft.com/office/2009/07/customui" onLoad="CustomUIOnLoad">
    <ribbon startFromScratch="false">
        <tabs>
            <tab id="tab-1" label="mes menu switchables">
                <group id="group_1" label="ACCEUIL">
                    <button id="button_1" onAction="button_1_Click" label="menu1"/>
                    <button id="button_2" onAction="button_2_Click" label="menu2"/>
                    <button id="button_3" onAction="button_3_Click" label="menu3"/>
                </group>
                <group id="group_2" label="menu 1" getVisible="group_2_Getvisible">
                    <button id="button_4" onAction="button_4_Click" imageMso="NameCreateFromSelection" size="large"/>
                    <button id="button_5" onAction="button_5_Click" imageMso="ViewDocumentActionsPane" size="large"/>
                    <button id="button_6" onAction="button_6_Click" imageMso="WatchWindow" size="large"/>
                    <button id="button_7" onAction="button_7_Click" imageMso="UpgradeWorkbook" size="large"/>
                </group>
                <group id="group_3" label="menu 2" getVisible="group_3_Getvisible">
                    <button id="button_8" onAction="button_8_Click" imageMso="EditQuery" size="large"/>
                    <button id="button_9" onAction="button_9_Click" imageMso="BrightnessLess" size="large"/>
                    <button id="button_10" onAction="button_10_Click" imageMso="SpeakStop" size="large"/>
                </group>
                <group id="group_4" label="menu 3" getVisible="group_4_Getvisible">
                    <button id="button_11" onAction="button_11_Click" imageMso="QueryParameters" size="large"/>
                    <button id="button_12" onAction="button_12_Click" imageMso="NameCreateFromSelection" size="large"/>
                    <button id="button_13" onAction="button_13_Click" imageMso="XmlDataRefresh" size="large"/>
                    <button id="button_14" onAction="button_14_Click" imageMso="TableStylesGalleryExcel" size="large"/>
                    <button id="button_15" onAction="button_15_Click" imageMso="InkColorMoreColorsDialog" size="large"/>
                    <button id="button_16" onAction="button_16_Click" imageMso="DataValidationClearValidationCircles" size="large"/>
                </group>
            </tab>
        </tabs>
    </ribbon>
</customUI>

les callbacks
VB:
'callback created by ''creatorRibbonX''
'[createRibbonX Application] created by ''patricktoulon''
'Version 2023 Beta 4.3


Public myRibbon As IRibbonUI
Public ActiVmenu&
'Callback for customUI.onLoad
Sub CustomUIOnLoad(ribbon As IRibbonUI)
Set myRibbon = ribbon
 End Sub
Sub refresh()
myRibbon.InvalidateControl ("group_2")
myRibbon.InvalidateControl ("group_3")
myRibbon.InvalidateControl ("group_4")
End Sub
'procedure ''onAction du bouton [ID:''button_1''  Label:''menu1'']
'dans le parent [group_1''  Label:''ACCEUIL'']
Sub button_1_Click(control As IRibbonControl)
ActiVmenu = 1
refresh
End Sub

'procedure ''onAction du bouton [ID:''button_2''  Label:''menu2'']
'dans le parent [group_1''  Label:''ACCEUIL'']
Sub button_2_Click(control As IRibbonControl)
ActiVmenu = 2
refresh
End Sub

'procedure ''onAction du bouton [ID:''button_3''  Label:''menu3'']
'dans le parent [group_1''  Label:''ACCEUIL'']
Sub button_3_Click(control As IRibbonControl)
ActiVmenu = 3
refresh
End Sub

'procedure("getvisible") du group[ID:''group_2''  Label:''menu 1'']
'dans le parent [tab-1''  Label:''mes menu switchables'']
'valeur par defaut
Sub group_2_Getvisible(control As IRibbonControl, ByRef returnedVal)
 returnedVal = ActiVmenu = 1
End Sub
'procedure("getvisible") du group[ID:''group_3''  Label:''menu 2'']
'dans le parent [tab-1''  Label:''mes menu switchables'']
'valeur par defaut
Sub group_3_Getvisible(control As IRibbonControl, ByRef returnedVal)
 returnedVal = ActiVmenu = 2
End Sub
'procedure("getvisible") du group[ID:''group_4''  Label:''menu 3'']
'dans le parent [tab-1''  Label:''mes menu switchables'']
'valeur par defaut
Sub group_4_Getvisible(control As IRibbonControl, ByRef returnedVal)
 returnedVal = ActiVmenu = 3
End Sub





'procedure ''onAction du bouton [ID:''button_4''  Label:'''']
'dans le parent [group_2''  Label:''menu 1'']
Sub button_4_Click(control As IRibbonControl)
MsgBox " vous avez cliqué sur le [button] id: button_4"
End Sub

'procedure ''onAction du bouton [ID:''button_5''  Label:'''']
'dans le parent [group_2''  Label:''menu 1'']
Sub button_5_Click(control As IRibbonControl)
MsgBox " vous avez cliqué sur le [button] id: button_5"
End Sub

'procedure ''onAction du bouton [ID:''button_6''  Label:'''']
'dans le parent [group_2''  Label:''menu 1'']
Sub button_6_Click(control As IRibbonControl)
MsgBox " vous avez cliqué sur le [button] id: button_6"
End Sub

'procedure ''onAction du bouton [ID:''button_7''  Label:'''']
'dans le parent [group_2''  Label:''menu 1'']
Sub button_7_Click(control As IRibbonControl)
MsgBox " vous avez cliqué sur le [button] id: button_7"
End Sub


'procedure ''onAction du bouton [ID:''button_8''  Label:'''']
'dans le parent [group_3''  Label:''menu 2'']
Sub button_8_Click(control As IRibbonControl)
MsgBox " vous avez cliqué sur le [button] id: button_8"
End Sub

'procedure ''onAction du bouton [ID:''button_9''  Label:'''']
'dans le parent [group_3''  Label:''menu 2'']
Sub button_9_Click(control As IRibbonControl)
MsgBox " vous avez cliqué sur le [button] id: button_9"
End Sub

'procedure ''onAction du bouton [ID:''button_10''  Label:'''']
'dans le parent [group_3''  Label:''menu 2'']
Sub button_10_Click(control As IRibbonControl)
MsgBox " vous avez cliqué sur le [button] id: button_10"
End Sub


'procedure ''onAction du bouton [ID:''button_11''  Label:'''']
'dans le parent [group_4''  Label:''menu 3'']
Sub button_11_Click(control As IRibbonControl)
MsgBox " vous avez cliqué sur le [button] id: button_11"
End Sub

'procedure ''onAction du bouton [ID:''button_12''  Label:'''']
'dans le parent [group_4''  Label:''menu 3'']
Sub button_12_Click(control As IRibbonControl)
MsgBox " vous avez cliqué sur le [button] id: button_12"
End Sub

'procedure ''onAction du bouton [ID:''button_13''  Label:'''']
'dans le parent [group_4''  Label:''menu 3'']
Sub button_13_Click(control As IRibbonControl)
MsgBox " vous avez cliqué sur le [button] id: button_13"
End Sub

'procedure ''onAction du bouton [ID:''button_14''  Label:'''']
'dans le parent [group_4''  Label:''menu 3'']
Sub button_14_Click(control As IRibbonControl)
MsgBox " vous avez cliqué sur le [button] id: button_14"
End Sub

'procedure ''onAction du bouton [ID:''button_15''  Label:'''']
'dans le parent [group_4''  Label:''menu 3'']
Sub button_15_Click(control As IRibbonControl)
MsgBox " vous avez cliqué sur le [button] id: button_15"
End Sub

'procedure ''onAction du bouton [ID:''button_16''  Label:'''']
'dans le parent [group_4''  Label:''menu 3'']
Sub button_16_Click(control As IRibbonControl)
MsgBox " vous avez cliqué sur le [button] id: button_16"
End Sub
 

RyuAutodidacte

XLDnaute Impliqué
Re, j'ai voulu tester , mai j'ai du louper qqd chose car je n'ai pas réussi à le faire marcher .... pourquoi ?
 

Pièces jointes

  • Sample.xlsm
    19.5 KB · Affichages: 4

patricktoulon

XLDnaute Barbatruc
j'avais laissé le piege "azerty" mille excuses
et tes fichiers xml n'ont pas le bon BOM
quand tu fait enregistrer sous dans bloknote
il faut vérifier le format en bas à droite
sinon si le xml est plus complexe ca va planter sans que l'on sache pour quoi
et surtout pour que les caractères particulier"é'èàê" etc soit pris comme tels sinon customUI ne l'accepte pas
regarde
 

patricktoulon

XLDnaute Barbatruc
re
un switchenabled pour bouton

exemple 1
LE CLICK SUR BOUTON ALLUME LE SUIVANT etc........

le XML
XML:
<?xml version="1.0" encoding="utf-8" standalone="yes"?>
<customUI xmlns="http://schemas.microsoft.com/office/2009/07/customui" onLoad="CustomUIOnLoad">
    <ribbon startFromScratch="false">
        <tabs>
            <tab id="tab_1" label="MES BOUTONS">
                <group id="group-0" label="ACCEUIL">
                    <button id="button_1" onAction="button_1_Click" imageMso="FileClose" label="BOUTON 1" getEnabled="button_1_GetEnabled" size="large"/>
                    <button id="button_2" onAction="button_2_Click" imageMso="ObjectBorderOutlineColorMoreColorsDialog" label="BOUTON 2" getEnabled="button_2_GetEnabled" size="large"/>
                    <button id="button_3" onAction="button_3_Click" imageMso="ErrorChecking" label="BOUTON 3" getEnabled="button_3_GetEnabled" size="large"/>
                    <button id="button_4" onAction="button_4_Click" imageMso="BrightnessLess" label="BOUTON 4" getEnabled="button_4_GetEnabled" size="large"/>
                </group>
            </tab>
        </tabs>
    </ribbon>
</customUI>

les callbacks
VB:
'callback created by ''creatorRibbonX''
'[createRibbonX Application] created by ''patricktoulon''
'Version 2023 Beta 4.3
'POUR MEMO
'L 'objet IRibbonUI possède deux méthodes :
'1° Invalidate() qui actualise en une seule fois tous les contrôles personnalisés du classeur.
'2° InvalidateControl("ControlID As String") qui actualise un contrôle particulier (ControlID correspond à l'identificateur unique du contrôle).


Public myRibbon As IRibbonUI
Public b(1 To 4) As Boolean
'Callback for customUI.onLoad
Sub CustomUIOnLoad(ribbon As IRibbonUI)
    Set myRibbon = ribbon
    b(1) = True
End Sub

Sub refresh()
    myRibbon.Invalidate
End Sub


'procedure ''onAction du bouton [ID:''button_1''  Label:''BOUTON 1'']
'dans le parent [group-0''  Label:''ACCEUIL'']
Sub button_1_Click(control As IRibbonControl)
    For i = 1 To 4: b(i) = False:: Next
    b(2) = True
    refresh
    'MsgBox " vous avez cliqué sur le [button] id: button_1"
End Sub
'procedure ''onAction du bouton [ID:''button_2''  Label:''BOUTON 2'']
'dans le parent [group-0''  Label:''ACCEUIL'']
Sub button_2_Click(control As IRibbonControl)
    For i = 1 To 4: b(i) = False: Next
    b(3) = True
     refresh
   'MsgBox " vous avez cliqué sur le [button] id: button_2"
End Sub

'procedure ''onAction du bouton [ID:''button_3''  Label:''BOUTON 3'']
'dans le parent [group-0''  Label:''ACCEUIL'']
Sub button_3_Click(control As IRibbonControl)
    For i = 1 To 4: b(i) = False: Next
    b(4) = True
    refresh
    'MsgBox " vous avez cliqué sur le [button] id: button_3"
End Sub

'procedure ''onAction du bouton [ID:''button_4''  Label:''BOUTON 4'']
'dans le parent [group-0''  Label:''ACCEUIL'']
Sub button_4_Click(control As IRibbonControl)
    For i = 1 To 4: b(i) = False
    Next: b(1) = True
    refresh
    'MsgBox " vous avez cliqué sur le [button] id: button_4"
End Sub

'procedure("getEnabled") du button[ID:''button_1''  Label:''BOUTON 1'']
'dans le parent [group-0''  Label:''ACCEUIL'']
'valeur par defaut
Sub button_1_GetEnabled(control As IRibbonControl, ByRef returnedVal)
    returnedVal = b(1)
End Sub


'procedure("getEnabled") du button[ID:''button_2''  Label:''BOUTON 2'']
'dans le parent [group-0''  Label:''ACCEUIL'']
'valeur par defaut
Sub button_2_GetEnabled(control As IRibbonControl, ByRef returnedVal)
    returnedVal = b(2)
End Sub

'procedure("getEnabled") du button[ID:''button_3''  Label:''BOUTON 3'']
'dans le parent [group-0''  Label:''ACCEUIL'']
'valeur par defaut
Sub button_3_GetEnabled(control As IRibbonControl, ByRef returnedVal)
    returnedVal = b(3)
End Sub


'procedure("getEnabled") du button[ID:''button_4''  Label:''BOUTON 4'']
'dans le parent [group-0''  Label:''ACCEUIL'']
'valeur par defaut
Sub button_4_GetEnabled(control As IRibbonControl, ByRef returnedVal)
    returnedVal = b(4)
End Sub


EXEMPLE 2
LE CLICK SUR BOUTON L' ÉTEINT ET ALLUME TOUT LES AUTRES



le XML
XML:
<?xml version="1.0" encoding="utf-8" standalone="yes"?>
<customUI xmlns="http://schemas.microsoft.com/office/2009/07/customui" onLoad="CustomUIOnLoad">
    <ribbon startFromScratch="false">
        <tabs>
            <tab id="tab_1" label="MES BOUTONS">
                <group id="group-0" label="ACCEUIL">
                    <button id="button_1" onAction="button_1_Click" imageMso="FileClose" label="BOUTON 1" getEnabled="button_1_GetEnabled" size="large"/>
                    <button id="button_2" onAction="button_2_Click" imageMso="ObjectBorderOutlineColorMoreColorsDialog" label="BOUTON 2" getEnabled="button_2_GetEnabled" size="large"/>
                    <button id="button_3" onAction="button_3_Click" imageMso="ErrorChecking" label="BOUTON 3" getEnabled="button_3_GetEnabled" size="large"/>
                    <button id="button_4" onAction="button_4_Click" imageMso="BrightnessLess" label="BOUTON 4" getEnabled="button_4_GetEnabled" size="large"/>
                </group>
            </tab>
        </tabs>
    </ribbon>
</customUI>

les callbacks
VB:
'callback created by ''creatorRibbonX''
'[createRibbonX Application] created by ''patricktoulon''
'Version 2023 Beta 4.3
'POUR MEMO
'L 'objet IRibbonUI possède deux méthodes :
'1° Invalidate() qui actualise en une seule fois tous les contrôles personnalisés du classeur.
'2° InvalidateControl("ControlID As String") qui actualise un contrôle particulier (ControlID correspond à l'identificateur unique du contrôle).


Public myRibbon As IRibbonUI
Public b(1 To 4) As Boolean
'Callback for customUI.onLoad
Sub CustomUIOnLoad(ribbon As IRibbonUI)
    Set myRibbon = ribbon
    b(1) = True
End Sub

Sub refresh()
    myRibbon.Invalidate
End Sub


'procedure ''onAction du bouton [ID:''button_1''  Label:''BOUTON 1'']
'dans le parent [group-0''  Label:''ACCEUIL'']
Sub button_1_Click(control As IRibbonControl)
    For i = 1 To 4: b(i) = True:: Next
    b(1) = False
    refresh
    'MsgBox " vous avez cliqué sur le [button] id: button_1"
End Sub
'procedure ''onAction du bouton [ID:''button_2''  Label:''BOUTON 2'']
'dans le parent [group-0''  Label:''ACCEUIL'']
Sub button_2_Click(control As IRibbonControl)
    For i = 1 To 4: b(i) = True: Next
    b(2) = False
     refresh
   'MsgBox " vous avez cliqué sur le [button] id: button_2"
End Sub

'procedure ''onAction du bouton [ID:''button_3''  Label:''BOUTON 3'']
'dans le parent [group-0''  Label:''ACCEUIL'']
Sub button_3_Click(control As IRibbonControl)
    For i = 1 To 4: b(i) = True: Next
    b(3) = False
    refresh
    'MsgBox " vous avez cliqué sur le [button] id: button_3"
End Sub

'procedure ''onAction du bouton [ID:''button_4''  Label:''BOUTON 4'']
'dans le parent [group-0''  Label:''ACCEUIL'']
Sub button_4_Click(control As IRibbonControl)
    For i = 1 To 4: b(i) = True
    Next: b(4) = False
    refresh
    'MsgBox " vous avez cliqué sur le [button] id: button_4"
End Sub

'procedure("getEnabled") du button[ID:''button_1''  Label:''BOUTON 1'']
'dans le parent [group-0''  Label:''ACCEUIL'']
'valeur par defaut
Sub button_1_GetEnabled(control As IRibbonControl, ByRef returnedVal)
    returnedVal = b(1)
End Sub


'procedure("getEnabled") du button[ID:''button_2''  Label:''BOUTON 2'']
'dans le parent [group-0''  Label:''ACCEUIL'']
'valeur par defaut
Sub button_2_GetEnabled(control As IRibbonControl, ByRef returnedVal)
    returnedVal = b(2)
End Sub

'procedure("getEnabled") du button[ID:''button_3''  Label:''BOUTON 3'']
'dans le parent [group-0''  Label:''ACCEUIL'']
'valeur par defaut
Sub button_3_GetEnabled(control As IRibbonControl, ByRef returnedVal)
    returnedVal = b(3)
End Sub


'procedure("getEnabled") du button[ID:''button_4''  Label:''BOUTON 4'']
'dans le parent [group-0''  Label:''ACCEUIL'']
'valeur par defaut
Sub button_4_GetEnabled(control As IRibbonControl, ByRef returnedVal)
    returnedVal = b(4)
End Sub

les controls combobox



le XML
XML:
<?xml version="1.0" encoding="utf-8" standalone="yes"?>
<customUI xmlns="http://schemas.microsoft.com/office/2009/07/customui" onLoad="CustomUIOnLoad">
    <ribbon startFromScratch="false">
        <tabs>
            <tab id="tab-1" label="mon Onglet Perso">
                <group id="group_1" label="combobox simple">
                    <comboBox id="comboBox_1" onChange="comboBox_1_onChange">
                        <item id="item_1" label="toto"/>
                        <item id="item_2" label="titi"/>
                        <item id="item_3" label="riri"/>
                        <item id="item_4" label="fifi"/>
                    </comboBox>
                </group>
                <group id="group_2" label="combobox icon" imageMso="ErrorChecking">
                    <comboBox id="comboBox_2" onChange="comboBox_2_onChange" imageMso="ObjectAlignMenu">
                        <item id="item_5" label="toto" imageMso="MacroPlay"/>
                        <item id="item_6" label="titi" imageMso="MacroRelativeReferences"/>
                        <item id="item_7" label="riri" imageMso="MacroSecurity"/>
                    </comboBox>
                </group>
            </tab>
        </tabs>
    </ribbon>
</customUI>

les callbacks

VB:
'callback created by ''creatorRibbonX''
'[createRibbonX Application] created by ''patricktoulon''
'Version 2023 Beta 4.3
'POUR MEMO
'L 'objet IRibbonUI possède deux méthodes :
'1° Invalidate() qui actualise en une seule fois tous les contrôles personnalisés du classeur.
'2° InvalidateControl("ControlID As String") qui actualise un contrôle particulier (ControlID correspond à l'identificateur unique du contrôle).


Public myRibbon As IRibbonUI

'Callback for customUI.onLoad
Sub CustomUIOnLoad(ribbon As IRibbonUI)
Set myRibbon = ribbon
 End Sub

'procedure("onChange") de l'element[ID:''comboBox_1''  Label:'''']
'dans le parent [comboBox_1''  Label:''combobox simple'']
Sub comboBox_1_onChange(control As IRibbonControl, text As String)
MsgBox text
End Sub

'procedure("onChange") de l'element[ID:''comboBox_2''  Label:'''']
'dans le parent [comboBox_2''  Label:''combobox icon'']
Sub comboBox_2_onChange(control As IRibbonControl, text As String)
MsgBox text
End Sub
je continu ou tu en a assez
 

Usine à gaz

XLDnaute Barbatruc
Hello : j'y comprends rien mais continues lol
 

RyuAutodidacte

XLDnaute Impliqué
Hello Patrick
Update de la macro XMLCreator pour améliorer l'algo (Mac/PC) :
VB:
Sub XMLCreator()
Dim myEncodeXml$, myRibbonUI$, myRibbonUI14$, myRibbon$, StartUI$, StartUI14$, EndBalise$
Dim CheckBalise, BaliseClose, VA, x%, Col_Xml As New Collection, V$, TrueFalse As Boolean, MyIndent$, Col
Dim myUI$, myUI14$

    '---------------------------------
    myEncodeXml = "<?xml version=""1.0"" encoding=""UTF-8"" standalone=""yes""?>"
    myRibbonUI = "<customUI xmlns=""http://schemas.microsoft.com/office/2006/01/customui"">"
    myRibbonUI14 = "<customUI xmlns=""http://schemas.microsoft.com/office/2009/07/customui"">"
    myRibbon = "<ribbon startFromScratch=""false"">"
    '---------------------------------
    StartUI = myEncodeXml & vbNewLine & myRibbonUI & vbNewLine & vbTab & myRibbon & vbNewLine & Application.Rept(vbTab, 2) & "</tabs>"
    StartUI14 = myEncodeXml & vbNewLine & myRibbonUI14 & vbNewLine & vbTab & myRibbon & vbNewLine & Application.Rept(vbTab, 2) & "</tabs>"
    EndBalise = Application.Rept(vbTab, 2) & "</tabs>" & vbNewLine & vbTab & "</ribbon>" & vbNewLine & "</customUI>"
    '---------------------------------
    CheckBalise = Array("TAB", "GROUP", "BUTTONGROUP", "MENU", "BOX", "SPLITBUTTON")
    BaliseClose = Array("</tab>", "</group>", "</buttonGroup>", "</menu>", "</box>", "</splitButton>")
    '---------------------------------
    
    VA = Sheets("XML CREATION").Range("MyXML[[BALISE TYPE]:[ATTRIBUT 6]]").Value
    
    TrueFalse = False
    x = -1
    
    For i = LBound(VA) To UBound(VA)
        Check = Application.Match(VA(i, 1), CheckBalise, 0): If IsError(Check) Then Err.Clear: Check = 0
        If Check > 2 And x > 1 Then
            x = x - 1
        Else
            If TrueFalse = True And Check > 0 Then x = 0: TrueFalse = False
        End If
        
        V = Replace(Replace(Application.Trim(Join(Application.Index(VA, i, [{3,4,5,6,7,8}]))), " />", "/>"), " >", ">")
        MyIndent = Application.Rept(vbTab, x + 4)
        
        If Check > 0 Then
            If x = -1 Then
                Col_Xml.Add MyIndent & V
                Col_Xml.Add MyIndent & BaliseClose(Check - 1)
                x = x + 1
            Else
                Col_Xml.Add MyIndent & V, , Col_Xml.Count - x
                Col_Xml.Add MyIndent & BaliseClose(Check - 1), , Col_Xml.Count - x
                x = x + 1
            End If
        Else
            Col_Xml.Add MyIndent & V, , Col_Xml.Count - x
            TrueFalse = True
        End If
        
   Next
  
    For Each Col In Col_Xml
        myUI = myUI & Col & vbNewLine
        myUI14 = myUI14 & Col & vbNewLine
    Next
    
    myUI = StartUI & vbNewLine & myUI & EndBalise
    myUI14 = StartUI14 & vbNewLine & myUI14 & EndBalise
    
    Debug.Print myUI & vbNewLine & vbNewLine & myUI14
    
End Sub

XML:
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<customUI xmlns="http://schemas.microsoft.com/office/2009/07/customui">
    <ribbon startFromScratch="false">
        </tabs>
            <tab id="myTabID_1" label="NameLabelTab" visible="true/false">
                <group id ="myGroupID_1" label="NameLabelGroup">
                    <button id="myButtonID_1" label="NameLabelButton" onAction="MacroName" imageMso="NameImage" size="large"/>
                    <button id="myButtonID_2" label="NameLabelButton" onAction="MacroName" imageMso="NameImage" size="large"/>
                    <button id="myButtonID_3" label="NameLabelButton" onAction="MacroName" imageMso="NameImage" size="large"/>
                </group>
                <group id ="myGroupID_2" label="NameLabelGroup">
                    <button id="myButtonID_4" label="NameLabelButton" onAction="MacroName" imageMso="NameImage" size="large"/>
                    <button id="myButtonID_5" label="NameLabelButton" onAction="MacroName" imageMso="NameImage" size="large"/>
                    <button id="myButtonID_6" label="NameLabelButton" onAction="MacroName" imageMso="NameImage" size="large"/>
                    <separator id="mySeparatorID_1"/>
                    <button id="myButtonID_7" label="NameLabelButton" onAction="MacroName" imageMso="NameImage" size="large"/>
                </group>
                <group id ="myGroupID_3" label="NameLabelGroup">
                    <menu id="myMenuID_1" itemSize="large"/>
                        <button id="myButtonID_8" label="NameLabelButton" onAction="MacroName" imageMso="NameImage" size="large"/>
                        <button id="myButtonID_9" label="NameLabelButton" onAction="MacroName" imageMso="NameImage" size="large"/>
                        <button id="myButtonID_10" label="NameLabelButton" onAction="MacroName" imageMso="NameImage" size="large"/>
                        <button id="myButtonID_11" label="NameLabelButton" onAction="MacroName" imageMso="NameImage" size="large"/>
                        <button id="myButtonID_12" label="NameLabelButton" onAction="MacroName" imageMso="NameImage" size="large"/>
                    </menu>
                </group>
                <group id ="myGroupID_4" label="NameLabelGroup">
                    <splitButton id="mySplitButtonID_1">
                        <button id="myButtonID_13" label="NameLabelButton" onAction="MacroName" imageMso="NameImage" size="large"/>
                    </splitButton>
                    <menu id="myMenuID_2" itemSize="large"/>
                        <button id="myButtonID_14" label="NameLabelButton" onAction="MacroName" imageMso="NameImage" size="large"/>
                        <button id="myButtonID_15" label="NameLabelButton" onAction="MacroName" imageMso="NameImage" size="large"/>
                        <button id="myButtonID_16" label="NameLabelButton" onAction="MacroName" imageMso="NameImage" size="large"/>
                    </menu>
                </group>
                <group id ="myGroupID_5" label="NameLabelGroup">
                    <buttonGroup id="myButtonGroupID_1">
                        <button id="myButtonID_17" label="NameLabelButton" onAction="MacroName" imageMso="NameImage" size="large"/>
                        <button id="myButtonID_18" label="NameLabelButton" onAction="MacroName" imageMso="NameImage" size="large"/>
                        <button id="myButtonID_19" label="NameLabelButton" onAction="MacroName" imageMso="NameImage" size="large"/>
                        <button id="myButtonID_20" label="NameLabelButton" onAction="MacroName" imageMso="NameImage" size="large"/>
                    </buttonGroup>
                    <buttonGroup id="myButtonGroupID_2">
                        <button id="myButtonID_21" label="NameLabelButton" onAction="MacroName" imageMso="NameImage" size="large"/>
                        <button id="myButtonID_22" label="NameLabelButton" onAction="MacroName" imageMso="NameImage" size="large"/>
                        <button id="myButtonID_23" label="NameLabelButton" onAction="MacroName" imageMso="NameImage" size="large"/>
                    </buttonGroup>
                    <buttonGroup id="myButtonGroupID_3">
                        <toggleButton id="myToggleButtonID_1" label="NameLabelToggleButton" onAction="MacroName" imageMso="NameImage" size="large"/>
                        <toggleButton id="myToggleButtonID_2" label="NameLabelToggleButton" onAction="MacroName" imageMso="NameImage" size="large"/>
                        <button id="myButtonID_24" label="NameLabelButton" onAction="MacroName" imageMso="NameImage" size="large"/>
                    </buttonGroup>
                </group>
            </tab>
        </tabs>
    </ribbon>
</customUI>
 
Les cookies sont requis pour utiliser ce site. Vous devez les accepter pour continuer à utiliser le site. En savoir plus…