Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 39
Default Calling macro from a different addin

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 ToolsOptionsGeneral 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

  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 638
Default Calling macro from a different addin

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 ToolsOptionsGeneral 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


  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 39
Default Calling macro from a different addin

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 ToolsOptionsGeneral 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
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

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


Similar Threads
Thread Thread Starter Forum Replies Last Post
Calling Com addin from form button on sheet? Robin Hammond[_2_] Excel Programming 8 January 8th 05 03:03 AM
Calling addin Function from another workbook? thinkingfield[_8_] Excel Programming 1 November 11th 04 03:39 AM
Calling a sub from a addin in vba Roger[_9_] Excel Programming 4 November 3rd 03 10:39 AM
Calling an Excel Addin from VBA ABN Excel Programming 2 July 31st 03 02:33 PM
Calling an Excel Addin from VBA ABN Excel Programming 0 July 31st 03 02:02 PM


All times are GMT +1. The time now is 10:12 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Copyright ©2004-2025 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"