View Full Version : Ribbon and .dotm name collisions

Mr Axolotl
2014-03-10, 11:08 PM

I've been having a problem where a button's onAction invokes VBA code of the same name in a different addin. I have seen this problem in Word, but I imagine it would occur in Excel as well.

The problem is easy to replicate. Create a minimal Foo1.dotm (probably Foo1.xlam would do the same) with the following user interface consisting of a single button

<?xml version="1.0" encoding="utf-8"?>
<customUI onLoad="ribbonLoad" xmlns="htp://schemas.microsoft.com/office/2006/01/customui">
<tab id="Toolkit" label="Foo1">
<group id="Foo1" label="Foo1">
<box id="BoxX" boxStyle="vertical">
<button id="Button001" imageMso="Piggy"
onAction="foo" />

and with the following VBA code in a single module. (htp://... is intentional as this forum does not allow me to post links)

Option Explicit
Public ribbon As IRibbonUI

Private Sub ribbonLoad(arg As IRibbonUI)
Set ribbon = arg
End Sub

Private Sub foo(arg As IRibbonControl)
MsgBox "Foo1"
End Sub

When done, copy Foo1.dotm twice for Foo2.dotm and Foo3.dotm and change the XML

<tab id="Toolkit" label="Foo1"> to Foo2 and Foo3 respectively

and change the VBA

MsgBox "Foo1" to Foo2 and Foo3 as well.

onAction="foo" should remain the same in all three places.

In total, there should be three .dotm files. My hope would be that clicking the Foo button in the Foo1 addin would display Foo1, Foo2 in the Foo2 addin, and so on. However, all three Foo buttons apparently execute the same program in the first Foo1 addin, and all display Foo1. :frusty:

Clearly, a solution is not to have any such name conflicts. The problem is that the other addins participating in this are not under my control, and there is no guarantee that this sort of thing will not happen again when the user installs another addin.

What I think I need is to be able to write

onAction="Foo1.Module.foo"that is, a fully qualified name, so that I could unambiguoisly specify which foo is to be run. But that does not seem to work.

Suggestions are very welcome. Namespaces?

Andy Pope
2014-03-12, 03:53 PM
I tested in excel using addins but the same should hold for word dotm files.

In foo2.xlam I modified the onAction to include workbook name