I have an Excel Add-In with a number of small subs, that upon initializing creates a Custom tab on the Ribbon to control said subs. I use VBA string with XML code to modify Ribbon (see the code below).
The Add-In is meant to be shared with a number of users, most of whom already have some customization in place. The problem is, that Add-In deletes any custom settings user might have on his Excel Ribbon, be it tabs, buttons or a shortcut.
I've played with this problem for a few days and was unable to find a solution. I need it to add a custom tab to an already existing ribbon, rather then overwrite it.
Part of the sub that creates a Custom Tab for an Add-In controls is below
Sub CreateRibbon()
'create a custom ribbon menu'
Dim hFile As Long
Dim path As String, fileName As String, ribbonXML As String
hFile = FreeFile
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 startFromScratch='false'>" & vbNewLine
ribbonXML = ribbonXML + " <mso:qat/>" & vbNewLine
ribbonXML = ribbonXML + " <mso:tabs>" & vbNewLine
'tab'
ribbonXML = ribbonXML + " <mso:tab id='MicroHelpers' label='Helpers' insertBeforeQ='mso:TabFormat'>" & vbNewLine
'group'
ribbonXML = ribbonXML + " <mso:group id='MassFormulas' label='Mass Formula' autoScale='true'>" & vbNewLine
ribbonXML = ribbonXML + AddButtonXML("TextToNum", "WordCount", "Text To Num")
ribbonXML = ribbonXML + " </mso:group>" & 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
I'll be grateful for some guidance