Ribbon and .dotm name collisions

Mr Axolotl

New member
Joined
Apr 4, 2012
Messages
7
Reaction score
0
Points
0
Location
Central Europe
Hello,

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

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

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

Code:
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
Code:
<tab id="Toolkit" label="Foo1">
to Foo2 and Foo3 respectively

and change the VBA
Code:
MsgBox "Foo1"
to Foo2 and Foo3 as well.

Code:
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
Code:
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?
 
Last edited:
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

Code:
onAction="foo2.xlam!foo"
 
Back
Top