Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

Using same Class in several projects

2 views
Skip to first unread message

WhytheQ

unread,
Apr 15, 2008, 6:01:46 AM4/15/08
to
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.

Peter T

unread,
Apr 15, 2008, 12:46:41 PM4/15/08
to
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" <Why...@gmail.com> wrote in message
news:eaeba8f9-bfc4-4752...@b64g2000hsa.googlegroups.com...

WhytheQ

unread,
Apr 15, 2008, 3:19:34 PM4/15/08
to
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" <Whyt...@gmail.com> wrote in message


>
> news:eaeba8f9-bfc4-4752...@b64g2000hsa.googlegroups.com...
>
>
>
> > 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 -

Peter T

unread,
Apr 16, 2008, 4:31:57 AM4/16/08
to

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" <Why...@gmail.com> wrote in message

news:4d87b0d2-3113-4a5f...@8g2000hse.googlegroups.com...

0 new messages