PC Review


Reply
Thread Tools Rate Thread

Calling macro from a different addin

 
 
=?Utf-8?B?TmF5YW4=?=
Guest
Posts: n/a
 
      2nd Aug 2007
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

 
Reply With Quote
 
 
 
 
JW
Guest
Posts: n/a
 
      2nd Aug 2007
Simple. Just include the complete path to Source.xla in the OnAction
portion of the code.
..OnAction = "C:\Something\Source.xla!MyModule.MyMethod"

Nayan wrote:
> 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


 
Reply With Quote
 
=?Utf-8?B?TmF5YW4=?=
Guest
Posts: n/a
 
      3rd Aug 2007
Thanks JW. Its working. It never occured to me to qualify the Addin with its
path.

Thanks again.

Nayan

"JW" wrote:

> Simple. Just include the complete path to Source.xla in the OnAction
> portion of the code.
> ..OnAction = "C:\Something\Source.xla!MyModule.MyMethod"
>
> Nayan wrote:
> > 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

>
>

 
Reply With Quote
 
 
 
Reply

Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
AddIn - Calling functions from VBA =?Utf-8?B?R3JhaGFtQg==?= Microsoft Excel Discussion 3 3rd Oct 2005 05:20 PM
Calling Addin function? Brian Shafer Microsoft Excel Discussion 2 6th Jan 2004 11:37 PM
Calling a sub from a addin in vba Roger Microsoft Excel Programming 4 3rd Nov 2003 10:39 AM
Calling an Excel Addin from VBA ABN Microsoft Excel Programming 2 31st Jul 2003 02:33 PM
Calling an Excel Addin from VBA ABN Microsoft Excel Programming 0 31st Jul 2003 02:02 PM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 09:19 PM.