View Single Post
  #2   Report Post  
Posted to microsoft.public.excel.programming
Robin Hammond[_2_] Robin Hammond[_2_] is offline
external usenet poster
 
Posts: 575
Default Excel startup macros - visibility of...

If you put your code in an addin then

1. auto_open will run when the add-in loads,
2. functions are available in other worksheets simply using the name of the
function in a cell, or you can use Application.Run to reference macros in
the add-in
3. you can set a reference in other workbooks to the addin which should
allow you to use their functionality, including classes. e.g.

MyAddIn contains class modules

In a separate workbook, open VBE, set a ref to MyAddIn.

In a Sub

Dim clsTest as MyAddIn.clsMyClass
with clsTest
'your code
End with

You can either register the add-in with Excel in a small VB app as part of
an install package, or install the add-in to the XlStart folder, or the
add-ins folder and tell your users to browse for it.

Robin Hammond
www.enhanceddatasystems.com

"ghostWolf" wrote in message
...
I am faced with a problem where I would like to break out commonly used

code that has been duplicated in a number of spread sheets and put this
common code in a separate macro sheet that is automatically loaded when
Excel starts up.

The problem is that it appear that only sub procedures becomes

available/visible to other sheets.
My question is: Is it possible to access functions and sub procedures in a

auto loaded sheet from within other spread sheets?

I also need to know if it is possible to put generic class modules in a

starup macro sheet and still be able to access it from other sheets?
I have commonly used properties class definitions that I would like to

create instances of from other sheets - but I do not want to dublicate these
class modules in each spread sheet - hence the idea of putting them in a
auto loaded macro sheet.

All above tasks would be accessed from within sheet specific macros.

/g
--
Can't wait getting my hands on a real programming language such as Java