Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 103
Default Where to put code

On Mon, 26 Jan 2004 14:58:42 -0000, "Mervyn Thomas"
wrote:

Thanks Hank ! all that was very usefull and informative - only one
question - How do you call a macro that's in an XLA ? I couldn't figure out
how to do that!
Mervyn


Sorry for the delay; I still have a few residual computer problems and
wasn't on line yesterday.

There are a number of ways of doing this. If you manually type the
macro name into the appropriate box, you can run the macro straight
from the Run Macro dialog. You won't be able to see the name in the
list, but if you enter (for example)

TestAddIn.xla!MyProcedure

into the "Macro Name" text box and click the [Run] button, you'll be
able to run it. (In most cases it won't be necessary to qualify the
procedure name with the name of the add-in and the exclamation mark.
However if there are other macros with the same name around the place,
that would ensure that you run the correct one. For example, if you
have a Sub in the current workbook which is ALSO called MyProcedure,
then if you just type the procedure name into the run macro dialog
that'll be the one to run. Add the reference to the .xla as I've
shown, though, and the procedure in THAT file will run instead.)

You can also assign the macro to (say) a command button from the Forms
toolbar in the same way through the Assign Macro dialog. The only
thing to watch out for here is that even if you qualify the macro with
the .xla name, it won't stick; if the button finds a local procedure
with the same name as the one in your add-in, it will always run the
local one in preference. (If you look at the "Assign Macro" dialog,
you'll see why; it reverts to the unqualified macro name every time.)

To run the procedure from another VBA project (say, from the Click
event of a command button from the Control Toolbox toolbar, or even
from a standard procedure in a workbook), probably the simplest way is
to use Application.Run. For example:

Application.Run ("TestAddIn.xla!MyProcedure")

Hope this helps.

---------------------------------------------------------
Hank Scorpio
scorpionet who hates spam is at iprimus.com.au (You know what to do.)
* Please keep all replies in this Newsgroup. Thanks! *
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
split post code (zip code) out of cell that includes full address Concord Excel Discussion (Misc queries) 4 October 15th 09 06:59 PM
Code to conditional format all black after date specified in code? wx4usa Excel Discussion (Misc queries) 3 December 26th 08 07:06 PM
Drop Down/List w/Code and Definition, only code entered when selec Spiritdancer Excel Worksheet Functions 2 November 2nd 07 03:57 AM
Convert a Number Code to a Text Code Traye Excel Discussion (Misc queries) 3 April 6th 07 09:54 PM
copying vba code to a standard code module 1vagrowr Excel Discussion (Misc queries) 2 November 23rd 05 04:00 PM


All times are GMT +1. The time now is 07:06 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"