Calling macro from a different addin

N

Nayan

Hello,

(Env: Excel 2003 on windows xp professinal) .

I have 2 addins, Caller.xla and Source.xla

I am building a menu from Caller.xla and 'onaction' command of menu is
calling a method from Source.xla

-------code in
Caller.xla----------------------------------------------------------------
Set MainMenu = Application.CommandBars(1).Controls("myControl")
Set SubMenu = MainMenu .Controls.Add(msoControlButton, 1, , , True)

With SubMenu
.caption = "myCaption"
.Tag = "myTag"
.BeginGroup = True
.OnAction = "Source.xla!MyModule.MyMethod"
End With
-----------------------------------------------------------------------------------------------
The issue is that Excel is looking for Source.xla in a path set in "Default
File location" property set by Tools>Options>General tab.

If I set the path in this field to point to source.xla the code works fine.
Without setting this path when I click on this menu "MyCaption", I get a
messge that the Excel could not find the macro.

I have a situation where I can not set the Default path to point to
Source.xla.

In other word the question is, From a custom menu, how do I call a macro
from a different addin without any additinal settings.

Thanks in advance

Nayan
 
J

JW

Simple. Just include the complete path to Source.xla in the OnAction
portion of the code.
..OnAction = "C:\Something\Source.xla!MyModule.MyMethod"
 
N

Nayan

Thanks JW. Its working. It never occured to me to qualify the Addin with its
path.

Thanks again.

Nayan
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top