Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 160
Default how to access macro code

I have a large number (100) speedsheets which are all similar and make use of
the same vba code for data entry. I dont want to include the code in each
sheet (in case I need to modify it) So the code is in a separate sheet

If I make this an addin then it loads even if the user is doing something
else and doesn't need my code.

If I put a button on a bar or create a keyboard short cut then similarly
this is always available even when not needed

So what is the proper way to have code load automatically and be accesible
when one of my sheets is loaded, but not otherwise.

Many Thanks

--
Patrick
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 595
Default how to access macro code

Patrick

One way: Load the add-in automatically, even when not needed. In the
add-in, use application level events to fire whenever a workbook is opened.
In the workbooks that need the add-in, create a Custom Property that will
identify it. In the application level event, check the Custom Property and
create the shortcut/toolbar button if it exists. Use a different
application level event to delete the shortcut/toolbar button when the
workbook is closed.

I prefer to use the Workbook_Activate and _Deactivate events for this. That
way a workbook that doesn't need the add-in can be opened or activated and
those add-in specific controls are hidden.

--
Dick Kusleika
MVP - Excel
Excel Blog - Daily Dose of Excel
www.dicks-blog.com

"Patrick" wrote in message
...
I have a large number (100) speedsheets which are all similar and make use
of
the same vba code for data entry. I dont want to include the code in each
sheet (in case I need to modify it) So the code is in a separate sheet

If I make this an addin then it loads even if the user is doing something
else and doesn't need my code.

If I put a button on a bar or create a keyboard short cut then similarly
this is always available even when not needed

So what is the proper way to have code load automatically and be accesible
when one of my sheets is loaded, but not otherwise.

Many Thanks

--
Patrick



  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 160
Default how to access macro code

Thank you - most helpful

I have it working except...
To do application events I understand you need a class module and this needs
to be initialised.

Help says
Dim X As New EventClassModule

Sub InitializeApp()
Set X.App = Application
End Sub

but I need to run InitialiseApp when my addin starts

How do I do this??

I can do it manually but not when my addin starts


Thank you

Patrick

"Dick Kusleika" wrote:

Patrick

One way: Load the add-in automatically, even when not needed. In the
add-in, use application level events to fire whenever a workbook is opened.
In the workbooks that need the add-in, create a Custom Property that will
identify it. In the application level event, check the Custom Property and
create the shortcut/toolbar button if it exists. Use a different
application level event to delete the shortcut/toolbar button when the
workbook is closed.

I prefer to use the Workbook_Activate and _Deactivate events for this. That
way a workbook that doesn't need the add-in can be opened or activated and
those add-in specific controls are hidden.

--
Dick Kusleika
MVP - Excel
Excel Blog - Daily Dose of Excel
www.dicks-blog.com

"Patrick" wrote in message
...
I have a large number (100) speedsheets which are all similar and make use
of
the same vba code for data entry. I dont want to include the code in each
sheet (in case I need to modify it) So the code is in a separate sheet

If I make this an addin then it loads even if the user is doing something
else and doesn't need my code.

If I put a button on a bar or create a keyboard short cut then similarly
this is always available even when not needed

So what is the proper way to have code load automatically and be accesible
when one of my sheets is loaded, but not otherwise.

Many Thanks

--
Patrick




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
Using Access in Excel VB Code Michael Excel Discussion (Misc queries) 1 February 2nd 06 07:31 PM
How can I prevent access to code contained within Tab Lee Excel Worksheet Functions 1 September 21st 05 12:42 AM
Is there somewhere I can access Excel-VB code at once? Souljah[_3_] Excel Programming 1 April 29th 04 03:46 PM
Where to put code for access by all workbooks David Smith[_2_] Excel Programming 4 February 28th 04 12:25 AM
XL2000 VBA code to ACCESS 2000 Tom Rudski Excel Programming 1 August 20th 03 08:41 AM


All times are GMT +1. The time now is 03:03 PM.

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"