Posted to microsoft.public.excel.misc
|
|
Sharing VBA procedures; alternative to personal.xls?
Save the workbook as Add-in
See this small example
Debra Dalgleish's (Toolbar example from Dave Peterson)
http://www.contextures.com/xlToolbar02.html
--
Regards Ron de Bruin
http://www.rondebruin.nl/tips.htm
wrote in message ...
I have a workbook with a set of VBA procedures (subs and functions).
I want to use the same procedures in another (new) workbook. I know
that I could cut-and-paste into the VBA editor. I also know that I
could put the shared procedures into personal.xls.
I believe there is a "better" way -- at least, a way that I prefer,
and a way that I have used in the past without problems. This has
been explained in these newsgroups, but I cannot find the
explanation. And what I remember is not working for me.
As I recall, all I need to do is open the original workbook that
contains the VBA procedures in the same Excel instance in which I open
the new workbook (File / New / Blank Workbook).
That does not work for me now, regardless of whether I open the
original workbook before or after creating the new workbook.
What am I doing wrong?
Oh, I __can__ access the subs in the original workbook. Just not the
functions.
Does this method of sharing VBA procedures work only for subs? Is
there a special way that I must declare the functions for this method
of sharing to work?
I have declared the functions simply as "function foobar(arglist) as
type".
I notice that the module that contains the VBA procedures is in one
VBA project named for the original workbook, whereas the new workbook
is in a separate VBA project. Is that the problem? Or is that
correct, namely that each workbook is a separate VBA project?
Bottom line: How can I share VBA procedures -- functions as well as
subs -- between workbooks, ideally without using personal.xls?
FYI, I am using Office Excel 2003.
|