Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 101
Default Calling an XLA macro from code

How do I call an XLA macro from the code in another workbook?

Chrissy.


  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 2,253
Default Calling an XLA macro from code

Step1:

make sure the CALLED procedures:
are NOT private.
are NOT located in object modules (like thisworkbook or Sheet1)
are NOT located in module with OPTION PRIVATE MODULE

THEN
EITHER

use the RUN method to run the macro.

OR make a fixed reference to it:
in the VBE: give the Addin's VBAProject a meaningfull name.
by clicking on it in the ProjExplorer and Changing it's name in the
Properties window. E.g. TESTADDIN

THEN
in the VBE Tools/References Checkmark the XXX.xla in the list
then close.

this way you can call the procedures and you'll find the procedures
in the object browser with the linking workbook active.

EXAMPLES:
'CODE FOR CALLER.xls SHEET1 object module
Private Sub Worksheet_BeforeDoubleClick(ByVal Target As Range, Cancel As
Boolean)
'This works when the book has a REFERENCE to TESTaddin
Call showmsg(Target.Address)
End Sub

Private Sub Worksheet_SelectionChange(ByVal Target As Range)
Run "test.xla!showmsg", Target.Address
End Sub

'CODE FOR TEST.XLA Module1
Sub ShowMsg(sMsg As String)
MsgBox sMsg
End Sub


HTH :)


keepITcool

< email : keepitcool chello nl (with @ and .)
< homepage: http://members.chello.nl/keepitcool


"Chrissy" wrote:

How do I call an XLA macro from the code in another workbook?

Chrissy.




  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 58
Default Calling an XLA macro from code

Just to add...

Application.Run "Addin.xla!Mcr"

or if there are spaces in the book name:

Application.Run "'Addin 2.xla'!Mcr"

or if apostrophes/spaces:

Application.Run "'" & Replace("Addin's.xla", "'", "''") & "'!Mcr"


"Chrissy" wrote in message
...
How do I call an XLA macro from the code in another workbook?

Chrissy.




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 VBA code from html or javascript Brent E Excel Discussion (Misc queries) 0 October 16th 08 11:27 PM
Calling a bit of code from a sheet errors gearoi Excel Discussion (Misc queries) 2 September 6th 05 08:21 PM
calling a macro from within a loop Rick[_12_] Excel Programming 1 July 30th 03 11:52 PM
Calling macro in add-in. Clark B Excel Programming 1 July 24th 03 11:05 PM
Calling HTML Source code from within VBA for Excel Peter Dickson Excel Programming 0 July 9th 03 08:38 PM


All times are GMT +1. The time now is 12:40 AM.

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

About Us

"It's about Microsoft Excel"