Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 246
Default Using same Class in several projects

Hello All,

Another question in connection with class modules:

- clCommon is used in 20 workbooks.
- clCommon quite often has additional code added.

How do I avoid having to go through all 20 workbooks to change the
code in clCommon ?

Any help appreciated,
Jason.
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 5,600
Default Using same Class in several projects

Looks like you've got three options

1. Keep the class in one wb and call in from your other wb's.
Application.run or set a reference in all 20 wb's. Either way you'll need a
helper function in the class wb.

2. Maybe you only need code in one wb which can process all the other 20
wb's. Those would be empty of code, except possibly 20 open events to open
the main code wb if/as required.

3. You suggest manually updating new code in the 20 wb's is tedious.
Programmatically you can update code in the 20 wb's, or replace entire old
module with new module. In effect 'Remove' old (class) module, add new
(class) module from file.

Regards,
Peter T


"WhytheQ" wrote in message
...
Hello All,

Another question in connection with class modules:

- clCommon is used in 20 workbooks.
- clCommon quite often has additional code added.

How do I avoid having to go through all 20 workbooks to change the
code in clCommon ?

Any help appreciated,
Jason.



  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 246
Default Using same Class in several projects

Thanks for the help on this thread.

(In this particular situation Option 2 isn't possible as each workbook
does different things - the class just creates a report from each
wb...clMngmtReport....and each report is run at a different time of
day)

Have you got a personal preference Peter ?
1.Application.run
2.Reference
3.Adding/removing class programmatically - this could be done on
auto_open?

What is a "a helper function in the class wb."?

J




On 15 Apr, 17:46, "Peter T" <peter_t@discussions wrote:
Looks like you've got three options

1. Keep the class in one wb and call in from your other wb's.
Application.run or set a reference in all 20 wb's. Either way you'll need a
helper function in the class wb.

2. Maybe you only need code in one wb which can process all the other 20
wb's. Those would be empty of code, except possibly 20 open events to open
the main code wb if/as required.

3. You suggest manually updating new code in the 20 wb's is tedious.
Programmatically you can update code in the 20 wb's, or replace entire old
module with new module. In effect 'Remove' old (class) module, add new
(class) module from file.

Regards,
Peter T

"WhytheQ" wrote in message

...



Hello All,


Another question in connection with class modules:


- clCommon is used in 20 workbooks.
- clCommon quite often has additional code added.


How do I avoid having to go through all 20 workbooks to change the
code in clCommon ?


Any help appreciated,
Jason.- Hide quoted text -


- Show quoted text -




  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 5,600
Default Using same Class in several projects


It's impossible to suggest a preference as any would depend on the overall
scenario, taking perhaps many factors into consideration. Some general
comments:~

Application.Run
Pro: no need to set and manage references
Con: significantly less efficient than calling direct (probably only
relevant in time sensitive long loops).

Reference
Pro: Can call directly functions in normal modules and existing object
modules (sheet & thisworkbook modules but not ordinary Class modules). You
get intellisense.
Con: If a reference goes 'missing' problems will occur. More work to
establish the references in the first place.

With both the above you'd call a 'helper' function in a main module to
manage the class, accept input arguments and return resolute or create your
report, if that's the objective.

Add/removeclass programmatically
Two approaches. A main wb updates all the others when it knows there's a new
class module to be updated in the 20 wb's. Or each wb updates itself. In the
open event you ask - in theory yes but doubt you'd want to do that each time
(or does code in the class change that often!. Maybe the open event could
first check by some means if there the class module need replacing before
doing so.

Regards,
Peter T

"WhytheQ" wrote in message
...
Thanks for the help on this thread.

(In this particular situation Option 2 isn't possible as each workbook
does different things - the class just creates a report from each
wb...clMngmtReport....and each report is run at a different time of
day)

Have you got a personal preference Peter ?
1.Application.run
2.Reference
3.Adding/removing class programmatically - this could be done on
auto_open?

What is a "a helper function in the class wb."?

J




On 15 Apr, 17:46, "Peter T" <peter_t@discussions wrote:
Looks like you've got three options

1. Keep the class in one wb and call in from your other wb's.
Application.run or set a reference in all 20 wb's. Either way you'll

need a
helper function in the class wb.

2. Maybe you only need code in one wb which can process all the other 20
wb's. Those would be empty of code, except possibly 20 open events to

open
the main code wb if/as required.

3. You suggest manually updating new code in the 20 wb's is tedious.
Programmatically you can update code in the 20 wb's, or replace entire

old
module with new module. In effect 'Remove' old (class) module, add new
(class) module from file.

Regards,
Peter T

"WhytheQ" wrote in message


...



Hello All,


Another question in connection with class modules:


- clCommon is used in 20 workbooks.
- clCommon quite often has additional code added.


How do I avoid having to go through all 20 workbooks to change the
code in clCommon ?


Any help appreciated,
Jason.- Hide quoted text -


- Show quoted text -






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
Error when returning user-defined class from "factory" class... George Excel Programming 5 October 2nd 07 05:58 PM
Class programming - how to return chartobject from a class? [email protected] Excel Programming 3 October 11th 06 12:07 PM
Class modules: parametrize class object fields Jean-Pierre Bidon Excel Programming 11 August 31st 06 02:49 PM
How to become a better programmer, post college. More projects or less projects. Matt Somers Excel Programming 1 February 12th 04 01:54 PM
RaiseEvent from a class contained in a 2nd class collection? Andrew[_16_] Excel Programming 2 January 6th 04 04:22 PM


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