Refrence a workbook procedure from another workbook

G

Guest

Hi everyone!
I have many workbooks that basicaly do the same thing with different data.
Now I copy all the code ( 15 procedures) into the new workbook each time I
need to creat a new workbookith new data . My question is :Is it possible to
have one workbook somewhere in the server with all macros and codes and and
use it as a refrence to other workbooks (use tools\refrence\...) and just use
the macros without actually copying them to the new workbooks . If yes how? I
tried to do but I get an error(name conflict with existing project,object
library).
Thanks :)
 
A

Alan

Yes, I have several files that are accessed through the network for
formatting reports and such. I set up a toolbar to load when the workbook
opens that asks the user to install the toolbar. If yes is chosen, the
toolbar installs. The toolbar automatically sets the correct link to the
workbook. I use this method so if I make any changes to the file the user
does not have to reinstall the toolbar.

Regards,

Alan
 
G

Guest

Hi Alan,
I guess I need to explain more about the task Im trying to accomplish. Let
say I have the "workbook1.xls" with some macros in it ( exp. sorting a
database in sheet 1) somewhere in our server, now I have to create a new
"workbook2" for a different client but instead of rewriting the sort macro
again in a module I want to use the macro which I have in "workbook1" by
refrencing to it in my code. Is it possible?
Thanks
 
A

Alan

Use a Workbook_Open in the ThisWorkbook module of the workbook.
In that Open event, place code to install a toolbar when the workbook opens,
referencing the sort macro name in the construction of the toolbar
Under the Open event macro, place the sort macro code.
Since the toolbar is constructed from code within your sort module workbook,
it automatically references the correct location of the macros when it
installs.

When running a macro from the toolbar the module workbook will open and will
become the activewindow. You'll need to insert the activewindow.activatenext
statement in your code to regain focus before your code starts.

I use this method when multiple users want access. This makes sure we are
all working on the same page, as they say, and I don't have to install any
modules on user computers. This facilitates changes that might be made to
the code. The changes are made in one place and are not noticed by the user.
That method, after a change, requires going to every computer running the
macros. Macros used for my personal job duties remain in modules on my local
drive.

I use the toolbar as a multipurpose tool, allowing access to macros and
templates. In building the toolbar include macros which go out and bring
templates to the desktop. I use them for just about everything. I can build
it from one location and control it from one location.

Man, I just went on and on didn't I.

Regards,

Alan
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top