0

I'm working with VBA in Word. I have to have a copy of my work in txt files. I'm saving content of every module/class/form.

Now, I need to save also custom ribbon. I don't know how to get access to ribbon xml. I know how to manipulate my ribbons (create or disable/enable buttons and other funny things) but I dont know how to get whole xml.

I'm generating my txt files using BeforeSave event (before every save I make a txt copy of my macros) - I'd like to save copy of ribbon too.

There are a lot of examples how to load or change ribbon, but about exporting existing ribbon using VBA I can't find anything.

deku
  • 85
  • 10

1 Answers1

0

Try this link from Microsoft. The core of the code is here:

Private Sub AddHighlightRibbon()
Dim ribbonXml As String

ribbonXml = "<mso:customUI xmlns:mso=""http://schemas.microsoft.com/office/2009/07/customui"">"
ribbonXml = ribbonXml + "  <mso:ribbon>"
ribbonXml = ribbonXml + "    <mso:qat/>"
ribbonXml = ribbonXml + "    <mso:tabs>"
ribbonXml = ribbonXml + "      <mso:tab id=""highlightTab"" label=""Highlight"" insertBeforeQ=""mso:TabFormat"">"
ribbonXml = ribbonXml + "        <mso:group id=""testGroup"" label=""Test"" autoScale=""true"">"
ribbonXml = ribbonXml + "          <mso:button id=""highlightManualTasks"" label=""Toggle Manual Task Color"" "
ribbonXml = ribbonXml + "imageMso=""DiagramTargetInsertClassic"" onAction=""ToggleManualTasksColor""/>"
ribbonXml = ribbonXml + "        </mso:group>"
ribbonXml = ribbonXml + "      </mso:tab>"
ribbonXml = ribbonXml + "    </mso:tabs>"
ribbonXml = ribbonXml + "  </mso:ribbon>"
ribbonXml = ribbonXml + "</mso:customUI>"

ActiveProject.SetCustomUI (ribbonXml)

End Sub

  • Actually, that's the reverse of what you want, isn't it? This will import a ribbon, not export. –  Nov 25 '16 at 15:33
  • Yes, this is reverse of that what I want. Thanks anyway. – deku Dec 05 '16 at 11:40