Search code examples
vbams-wordribbonoffice-2010

How to connect customUI events to macros in Word 2010?


I have a MS Word 2010 macro-enabled document template (.dotm file). I am working on embedding some custom Ribbon UI components by means of a customUI\customUI14.xml file within the .dotm archive.

The controls show up fine, but I am unable to link up the onAction events described in the XML with any of the macros defined in the template. I think the method signatures are correct, but I must be referencing them incorrectly in the XML. What am I doing wrong?

Here's the XML:

<mso:customUI xmlns:x2="http://schemas.microsoft.com/office/2009/07/customui/macro" xmlns:x1="DPOfcX.DocumentRibbon" xmlns:mso="http://schemas.microsoft.com/office/2009/07/customui">
    <mso:ribbon>
        <mso:tabs>
            <mso:tab idQ="mso:TabHome">
                <mso:group id="TestGroup" label="TestGroup" autoScale="true">
                    <mso:button onAction="SendAsEmail.SendAsEmailRibbon" idQ="x2:TestSendAsEmail" label="Send As Email" imageMso="ListMacros" visible="true"/>
                    <mso:button onAction="SendAsEmail.ShowFormRibbon" idQ="x2:TestShowForm" label="Enter Letter Data" imageMso="ListMacros" visible="true"/>
                </mso:group>
            </mso:tab>
        </mso:tabs>
    </mso:ribbon>
</mso:customUI>

Here are the method signatures in the SendAsEmail module:

Sub ShowFormRibbon(IControl As IRibbonControl)

End Sub

Sub SendAsEmailRibbon(IControl As IRibbonControl)

End Sub

Solution

  • The problem was the idQ attributes in the button tags. I had originally taken these from a UI export. Once I changed them to id, the button events worked!