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
<tab id="myTabID_1" OPEN>
<group id ="myGroupID_1" OPEN>
<menu id="myMenuID_1" OPEN>
<separator id="mySeparatorID_1">
<button id="myButtonID_1">
<button id="myButtonID_2">
<separator id="mySeparatorID_2">
<button id="myButtonID_3">
<button id="myButtonID_4">
</menu id="myMenuID_1" CLOSE>
</group id ="myGroupID_1" CLOSE>
<group id ="myGroupID_2" OPEN>
<menu id="myMenuID_2" OPEN>
<separator id="mySeparatorID_3">
<button id="myButtonID_5">
<button id="myButtonID_6">
<separator id="mySeparatorID_4">
<button id="myButtonID_7">
<button id="myButtonID_8">
</menu id="myMenuID_2" CLOSE>
</group id ="myGroupID_2" CLOSE>
</tab id="myTabID_1" CLOSE>
<tab id="myTabID_1" label="NameLabelTab">
<group id ="myGroupID_1" label="NameLabelGroup">
<menu id="myMenuID_1" itemSize="large"/>
<separator id="mySeparatorID_1"/>
<button id="myButtonID_1" label="NameLabelButton" onAction="MacroName" imageMso="NameImage" size="large"/>
<button id="myButtonID_2" label="NameLabelButton" onAction="MacroName" imageMso="NameImage" size="large"/>
<separator id="mySeparatorID_2"/>
<button id="myButtonID_3" label="NameLabelButton" onAction="MacroName" imageMso="NameImage" size="large"/>
<button id="myButtonID_4" label="NameLabelButton" onAction="MacroName" imageMso="NameImage" size="large"/>
</menu>
</group>
<group id ="myGroupID_2" label="NameLabelGroup">
<menu id="myMenuID_2" itemSize="large"/>
<separator id="mySeparatorID_3"/>
<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_4"/>
<button id="myButtonID_7" label="NameLabelButton" onAction="MacroName" imageMso="NameImage" size="large"/>
<button id="myButtonID_8" label="NameLabelButton" onAction="MacroName" imageMso="NameImage" size="large"/>
</menu>
</group>
</tab>
<?xml version="1.0" encoding="utf-8" standalone="yes"?>
<customUI azerty="http://schemas.microsoft.com/office/2009/07/customui">
<ribbon startFromScratch="false">
<tabs>
<tab id="tab-1" label="mes macros persos">
<group id="group_1" label="Un menu dynamico">
<dynamicMenu id="dynamicMenu_1" getContent="dynamicMenu_1_RechargeMenu" label="Ma liste" invalidateContentOnDrop="true"/>
</group>
</tab>
</tabs>
</ribbon>
</customUI>
'callback created by ''creatorRibbonX''
'[createRibbonX Application] created by ''patricktoulon''
'Version 2023 Beta 4.3
'dans le group [id:''group_1'' label :''Un menu dynamico'']
'procedure de remplissage du menu dynamique du DynamicMenu[ID:''dynamicMenu_1'' Label:''Ma liste'']
'dans le parent [group_1'' Label:''Un menu dynamico'']
Public Sub dynamicMenu_1_RechargeMenu(ctl As IRibbonControl, ByRef content)
content = "<menu xmlns=""http://schemas.microsoft.com/office/2006/01/customui"" >"& vbcrlf 'ouverture de la balise menu
content = content '& code xml du content
content = content & "<menu>"
End Sub
content = content '& code xml du content
For Each ws In ThisWorkbook.Worksheets
content = content & "<button id=""" & Replace(ws.Name, " ", "_") & """ label=""" & ws.Name & """ tag=""" & _
ws.Name & """ imageMso=""MacroPlay"" onAction=""GoFeuille""/>"
Next
Sub GoFeuille(control As IRibbonControl)
Sheets(control.Tag).Activate
End Sub
Bien sur évidementtu me donnera un exemple de ton creator par table ?
alors pour commencer aujourd'hui
la 023 beta 4.3 du compilaeur
<?xml version="1.0" encoding="utf-8" standalone="yes"?>
<customUI azerty="http://schemas.microsoft.com/office/2009/07/customui" onLoad="CustomUIOnLoad">
<ribbon startFromScratch="false">
<tabs>
<tab id="tab-1" label="Onglet_0">
<group id="group-0" label="premiergroup">
<button id="button_1" onAction="button_1_Click" size="large" imageMso="ObjectBorderOutlineColorMoreColorsDialog" getVisible="button_1_Getvisible"/>
<button id="button_2" onAction="button_2_Click" getVisible="button_2_Getvisible" imageMso="SortClear" size="large"/>
</group>
</tab>
</tabs>
</ribbon>
</customUI>
'callback created by ''creatorRibbonX''
'[createRibbonX Application] created by ''patricktoulon''
'Version 2023 Beta 4.3
Public myRibbon As IRibbonUI
Public visibility As Boolean
'Callback for customUI.onLoad
Sub CustomUIOnLoad(ribbon As IRibbonUI)
Set myRibbon = ribbon
End Sub
'procedure ''onAction du bouton [ID:''button_1'' Label:'''']
'dans le parent [group-0'' Label:''premiergroup'']
Sub button_1_Click(control As IRibbonControl)
visibility = Not visibility
myRibbon.InvalidateControl ("button_1")
myRibbon.InvalidateControl ("button_2")
MsgBox " vous avez cliqué sur le [button] id: button_1"
End Sub
'procedure("getvisible") du button[ID:''button_1'' Label:'''']
'dans le parent [group-0'' Label:''premiergroup'']
'valeur par defaut
Sub button_1_Getvisible(control As IRibbonControl, ByRef returnedVal)
returnedVal = visibility
End Sub
'procedure ''onAction du bouton [ID:''button_2'' Label:'''']
'dans le parent [group-0'' Label:''premiergroup'']
Sub button_2_Click(control As IRibbonControl)
visibility = Not visibility
myRibbon.InvalidateControl ("button_1")
myRibbon.InvalidateControl ("button_2")
MsgBox " vous avez cliqué sur le [button] id: button_2"
End Sub
'procedure("getvisible") du button[ID:''button_2'' Label:'''']
'dans le parent [group-0'' Label:''premiergroup'']
'valeur par defaut
Sub button_2_Getvisible(control As IRibbonControl, ByRef returnedVal)
returnedVal = Not visibility
End Sub
Sub CreateRibbonXML_Init() 'Initalisation du XML
Dim VA, V_Idx, i As Byte, y As Byte, Idx As New Collection, Balise As New Collection
Dim myTab, myGroup, myButtonGroup, myBox, myButton
Dim B, MyB
' PS : il faut mettre tous les attributs exisants de chaque balise
' ----- ARRAY DES BALISES ------------------------------------------------------------------------------------------------------------------------------------------
'---------------------------------
myTab = Array("<tab id=" & """myTabID_", "label=""NameLabelTab""", ">")
'---------------------------------
myGroup = Array("<group id =" & """myGroupID_", "label=""NameLabelGroup""", ">")
'---------------------------------
myButtonGroup = Array("<buttonGroup id=" & """myButtonGroupID_", ">")
'---------------------------------
myBox = Array("<box id=" & """myBoxID_", "boxstyle=""vertical/horizontal""", ">")
'---------------------------------
mySplitButton = Array("<splitButton id=" & """mySplitButtonID_", ">")
'---------------------------------
myMenu = Array("<menu id=" & """myMenuID_", "itemSize=""large""", "/>")
'---------------------------------
myButtons = Array("<button id=" & """myButtonID_", "label=""NameLabelButton""", "onAction=""MacroName""", "imageMso=""NameImage""", "size=""large""", "/>")
'---------------------------------
myToggleButton = Array("<toggleButton id=" & """myToggleButtonID_", "label=""NameLabelToggleButton""", "onAction=""MacroName""", "imageMso=""NameImage""", "size=""large""", "/>")
'---------------------------------
mySeparator = Array("<separator id=" & """mySeparatorID_", "/>")
'---------------------------------
' ----- ARRAY DES BALISES ------------------------------------------------------------------------------------------------------------------------------------------
' ----- ARRAY DES BALISES TYPE COL 1 + ARRAY DE CORRESPONDANCE DE B (MyB)--------------------------------------------------------------------------------------------
'---------------------------------
B = Array("TAB", "GROUP", "BUTTONGROUP", "BOX", "SPLITBUTTON", "MENU", "BUTTON", "TOGGLEBUTTON", "SEPARATOR")
'---------------------------------
MyB = Array(myTab, myGroup, myButtonGroup, myBox, mySplitButton, myMenu, myButtons, myToggleButton, mySeparator)
'---------------------------------
' ----- ARRAY DES BALISES TYPE COL 1 + ARRAY DE CORRESPONDANCE DE B (MyB)--------------------------------------------------------------------------------------------
For i = LBound(B) To UBound(B)
Balise.Add MyB(i), B(i)
Next
VA = Sheets("XML CREATION").Cells(1).CurrentRegion.Resize(, 1).Value
ReDim V_Idx(1 To UBound(VA) - 1, 1 To 7)
ReDim Result(1 To UBound(V_Idx), 1 To 1)
On Error Resume Next
For i = 2 To UBound(VA)
Idx.Add 1, VA(i, 1)
If Err Then
Err.Clear
nb = Idx(VA(i, 1)) + 1
Idx.Remove VA(i, 1)
Idx.Add nb, VA(i, 1)
End If
V_Idx(i - 1, 1) = Idx(VA(i, 1))
For y = LBound(Balise(VA(i, 1))) To UBound(Balise(VA(i, 1)))
If y = 0 Then
V_Idx(i - 1, y + 2) = Balise(VA(i, 1))(y) & Idx(VA(i, 1)) & """"
Else
V_Idx(i - 1, y + 2) = Balise(VA(i, 1))(y)
End If
Next
Next
On Error GoTo 0
Sheets("XML CREATION").Cells(2, 2).Resize(UBound(V_Idx), UBound(V_Idx, 2)) = V_Idx
End Sub
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<customUI xmlns="http://schemas.microsoft.com/office/2006/01/customui">
<ribbon startFromScratch="false">
</tabs>
<tab id="myTabID_1" label="NameLabelTab">
<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"/>
<separator id="mySeparatorID_1"/>
<button id="myButtonID_3" label="NameLabelButton" onAction="MacroName" imageMso="NameImage" size="large"/>
<button id="myButtonID_4" label="NameLabelButton" onAction="MacroName" imageMso="NameImage" size="large"/>
<button id="myButtonID_5" label="NameLabelButton" onAction="MacroName" imageMso="NameImage" size="large"/>
</group>
<group id ="myGroupID_2" label="NameLabelGroup">
<menu id="myMenuID_1" itemSize="large"/>
<button id="myButtonID_6" label="NameLabelButton" onAction="MacroName" imageMso="NameImage" size="large"/>
<button id="myButtonID_7" label="NameLabelButton" onAction="MacroName" imageMso="NameImage" size="large"/>
<separator id="mySeparatorID_2"/>
<button id="myButtonID_8" label="NameLabelButton" onAction="MacroName" imageMso="NameImage" size="large"/>
<button id="myButtonID_9" label="NameLabelButton" onAction="MacroName" imageMso="NameImage" size="large"/>
</menu>
</group>
<group id ="myGroupID_3" label="NameLabelGroup">
<button id="myButtonID_10" label="NameLabelButton" onAction="MacroName" imageMso="NameImage" size="large"/>
</group>
</tab>
</tabs>
</ribbon>
</customUI>
<?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">
<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"/>
<separator id="mySeparatorID_1"/>
<button id="myButtonID_3" label="NameLabelButton" onAction="MacroName" imageMso="NameImage" size="large"/>
<button id="myButtonID_4" label="NameLabelButton" onAction="MacroName" imageMso="NameImage" size="large"/>
<button id="myButtonID_5" label="NameLabelButton" onAction="MacroName" imageMso="NameImage" size="large"/>
</group>
<group id ="myGroupID_2" label="NameLabelGroup">
<menu id="myMenuID_1" itemSize="large"/>
<button id="myButtonID_6" label="NameLabelButton" onAction="MacroName" imageMso="NameImage" size="large"/>
<button id="myButtonID_7" label="NameLabelButton" onAction="MacroName" imageMso="NameImage" size="large"/>
<separator id="mySeparatorID_2"/>
<button id="myButtonID_8" label="NameLabelButton" onAction="MacroName" imageMso="NameImage" size="large"/>
<button id="myButtonID_9" label="NameLabelButton" onAction="MacroName" imageMso="NameImage" size="large"/>
</menu>
</group>
<group id ="myGroupID_3" label="NameLabelGroup">
<button id="myButtonID_10" label="NameLabelButton" onAction="MacroName" imageMso="NameImage" size="large"/>
</group>
</tab>
</tabs>
</ribbon>
</customUI>
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<customUI xmlns="http://schemas.microsoft.com/office/2006/01/customui">
<ribbon startFromScratch="false">
</tabs>
<tab id="myTabID_1" label="NameLabelTab">
<group id ="myGroupID_1" label="NameLabelGroup">
<button id="myButtonID_1" label="NameLabelButton" onAction="MacroName" size="large"/>
<button id="myButtonID_2" label="NameLabelButton" onAction="MacroName" size="large"/>
<separator id="mySeparatorID_1"/>
<button id="myButtonID_3" label="NameLabelButton" onAction="MacroName" imageMso="NameImage" size="large"/>
<button id="myButtonID_4" label="NameLabelButton" onAction="MacroName" imageMso="NameImage" size="large"/>
<button id="myButtonID_5" label="NameLabelButton" onAction="MacroName" imageMso="NameImage" size="large"/>
</group>
<group id ="myGroupID_2" label="NameLabelGroup">
<menu id="myMenuID_1" itemSize="large"/>
<button id="myButtonID_6" label="NameLabelButton" onAction="MacroName" imageMso="NameImage" size="large"/>
<button id="myButtonID_7" label="NameLabelButton" onAction="MacroName" imageMso="NameImage" size="large"/>
<separator id="mySeparatorID_2"/>
<button id="myButtonID_8" onAction="MacroName" imageMso="NameImage" size="large"/>
<button id="myButtonID_9" onAction="MacroName" imageMso="NameImage" size="large"/>
</menu>
</group>
<group id ="myGroupID_3">
<button id="myButtonID_10" onAction="MacroName" size="large"/>
</group>
</tab>
</tabs>
</ribbon>
</customUI>
<?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">
<group id ="myGroupID_1" label="NameLabelGroup">
<button id="myButtonID_1" label="NameLabelButton" onAction="MacroName" size="large"/>
<button id="myButtonID_2" label="NameLabelButton" onAction="MacroName" size="large"/>
<separator id="mySeparatorID_1"/>
<button id="myButtonID_3" label="NameLabelButton" onAction="MacroName" imageMso="NameImage" size="large"/>
<button id="myButtonID_4" label="NameLabelButton" onAction="MacroName" imageMso="NameImage" size="large"/>
<button id="myButtonID_5" label="NameLabelButton" onAction="MacroName" imageMso="NameImage" size="large"/>
</group>
<group id ="myGroupID_2" label="NameLabelGroup">
<menu id="myMenuID_1" itemSize="large"/>
<button id="myButtonID_6" label="NameLabelButton" onAction="MacroName" imageMso="NameImage" size="large"/>
<button id="myButtonID_7" label="NameLabelButton" onAction="MacroName" imageMso="NameImage" size="large"/>
<separator id="mySeparatorID_2"/>
<button id="myButtonID_8" onAction="MacroName" imageMso="NameImage" size="large"/>
<button id="myButtonID_9" onAction="MacroName" imageMso="NameImage" size="large"/>
</menu>
</group>
<group id ="myGroupID_3">
<button id="myButtonID_10" onAction="MacroName" size="large"/>
</group>
</tab>
</tabs>
</ribbon>
</customUI>
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 TrueFalse = True And Check > 0 Then x = 0: TrueFalse = False
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
j'ai fait un petit update de mon précédent message en rougeok je vais essayer ton fichier