Я сделал настраиваемую ленту через VBA, сама лента работает нормально, пока я вручную что-то не изменю в ленте. Когда я что-то меняю, все кнопки, созданные с помощью VBA, исчезают.
Как я могу предотвратить это?
Это мой код для настройки ленты:
Sub SetupRibbonEmp()
Dim hFile As Long
Dim path As String, fileName As String, ribbonXML As String, user As String
hFile = FreeFile
user = Environ("Username")
path = "C:\Users\" & user & "\AppData\Local\Microsoft\Office\"
fileName = "Excel.officeUI"
ribbonXML = "<mso:customUI xmlns:mso='http://schemas.microsoft.com/office/2009/07/customui'>" & vbNewLine
ribbonXML = ribbonXML + " <mso:ribbon>" & vbNewLine
ribbonXML = ribbonXML + " <mso:qat/>" & vbNewLine
ribbonXML = ribbonXML + " <mso:tabs>" & vbNewLine
ribbonXML = ribbonXML + " <mso:tab id='Planning' label='Planning' insertAfterMso='TabHome'>" & vbNewLine
ribbonXML = ribbonXML + " <mso:group id='Algemeen' label='Algemeen' autoScale='true'>" & vbNewLine
ribbonXML = ribbonXML + " <mso:button id='BureauplanningOpenen' label='Bureauplanning openen' " & vbNewLine
ribbonXML = ribbonXML + "imageMso='FormulaMoreFunctionsMenu' onAction='OpenBureauplanning'/>" & vbNewLine
ribbonXML = ribbonXML + " <mso:button id='CapaciteitsplanningOpenen' label='Capacitietsplanning openen' " & vbNewLine
ribbonXML = ribbonXML + "imageMso='AddressBook' onAction='OpenCapaciteitsplanning'/>" & vbNewLine
ribbonXML = ribbonXML + " <mso:button id='ProjectplanningOpenen' label='Projectplanning openen' " & vbNewLine
ribbonXML = ribbonXML + "imageMso='NewNotebookShort' onAction='OpenProjectplanning'/>" & vbNewLine
ribbonXML = ribbonXML + " <mso:button id='PersoonlijkePlanningOpenen' label='Medewerkersplanning openen' " & vbNewLine
ribbonXML = ribbonXML + "imageMso='CondolatoryEvent' onAction='OpenMedewerkersplanning'/>" & vbNewLine
ribbonXML = ribbonXML + " </mso:group>" & vbNewLine
ribbonXML = ribbonXML + " </mso:tab>" & vbNewLine
ribbonXML = ribbonXML + " </mso:tabs>" & vbNewLine
ribbonXML = ribbonXML + " </mso:ribbon>" & vbNewLine
ribbonXML = ribbonXML + "</mso:customUI>"
ribbonXML = Replace(ribbonXML, """", "")
Open path & fileName For Output Access Write As hFile
Print #hFile, ribbonXML
Close hFile
End Sub