0
votes

I've created a custom tab in the MS Word 2007 ribbon. The tab and all its features work fine and is saved within a macro enabled template. However, upon creating a new document based on this template, after saving it as either a normal Word document or macro enabled document and then closing it: when I reopen this document file, the custom tab has duplicated itself!

I'm rather limited in the tools I can use due to this being developed on heavily locked down computers and network. I'm restricted to the Custom UI Editor tool for the XML aspects, and VBA. I've included the start of the XML that creates the toolbar. If using a qualified tab id, the tab contents duplicates within the same tab. If using a non-qualified tab name, the entire tab duplicates itself in the ribbon.

I'm at a complete loss with this. Both instances of the custom toolbar work fine - it's just the fact there's two of them and lots of people will be using this template!

<?xml version="1.0" encoding="UTF-8" standalone ="yes"?>
<customUI xmlns="http://schemas.microsoft.com/office/2006/01/customui">
  <ribbon>
    <tabs>
    <tab id="rxTabCompanyName"
    label="Company Name Toolbar"
    insertBeforeMso="TabHome"
    tag="CompanyNameToolbarTag">
    <group id="rxgrpCompanyNameReportStyles"
           label="Report Text Styles">
      <box id="rxboxStyleX"
           boxStyle="horizontal">
        <menu id="rxmnuAllStyles"
              label="All Styles"
              supertip="List all styles"
              showLabel="true"
              image="AtkStyles"
              size="normal">

etc...

Any suggestions would be much appreciated.

5
Is this a global template that lives in the Startup folder or a template that you load into a document?Christina

5 Answers

0
votes

I think your problem is because you create a new document based on a template (*.dotx or *.dotm) and the template contains the Ribbon XML to display the ribbon tab. The new document will also contain the same XML and will display it's own version of the ribbon-tab.

I would suggest you create two template files:

  • one containing the Ribbon XML and any code you need to respond to user actions, load lists etc. Copy this template to the STARTUP folder for your Office installation.

  • the second is just a blank dotx without any code or ribbon, but with the look and contents that you want.

Create new documents based on the second template.

0
votes

Did you open and create the new document in a different version of MS-Word. I have seen the duplicates happen using MS-Word 2010 if the template was created in an earlier version.

I have put an extra reference to the ribbon namespace so that the ribbon is loaded in 2007 or 2010:

customUI xmlns="http://schemas.microsoft.com/office/2009/07/customui"

instead of:

customUI xmlns="http://schemas.microsoft.com/office/2006/01/customui

Ron de Bruin's tips explain a similar problem for Excel: http://www.rondebruin.nl/ribbonx20072010.htm

0
votes

Are you creating a new document based on a "dotm" template? OR Are you opening a "docm" file (used as a template) and save it under a new name?

Unlike Excel, Word links a new document to its template so the ribbon is not copied over to a new "instanced" document when it's based on a template (dotm).

If you're using a "docm" file as the template though, the (document level) ribbon will be copied to the "saved as" file.

This might not be what's happening but it's a possibility.

0
votes

Has a solution been found to this problem, as i'm experiencing the same issue whereby my .docm still contains customui?

my understanding of word documents and templates is that documents (.docx & docm) do not contain ribbon customisations whereas templates (.dotx & .dotm) do.

i have used the customui editor to remove the customisation, but still would like to know why this particular macro enabled document has retained the custom tab, since if i test this situation with a completely new template all subsequent documents do not contain customui.

0
votes

same Problem here... I don't know when it happens. But I want to share my Workaround to repair a lot of files. It's a Little vba script to remove the (doubled) custom Ribbon in each file in a Directory. Make sure that the .dotm file is not in the Directory!

Private Sub remover()
Dim re As String
Dim docdir As String

Dim fs As Object
Dim fVerz As Object
Dim docFiles As Object
Dim docFile As Object

Dim wdApp As Object
Dim wdDoc As Object

docdir = "C:\your\destination\path"

Set fs = CreateObject("scripting.FileSystemObject")
Set fVerz = fs.getFolder(docdir)
Set docFiles = fVerz.Files

'loop all files
For Each docFile In docFiles
    If InStr(docFile, "") > 0 Then
        re = Shell("zip """ & docFile & """ -d ""*customUI.xml""", vbNormalFocus)
    End If
Next docFile 
End Sub