View Single Post
  #8   Report Post  
Posted to microsoft.public.excel.programming
Jamie Collins Jamie Collins is offline
external usenet poster
 
Posts: 593
Default Need help w/ programming an Exel addin


keepITcool wrote:
Tom,

You keep referring to Chip's page.

My preferred method is to use ThisWorkbook's codemodule for this and
dispense with the class alltogether (as you may know).

I never had any problems, but are there any advantages to using a
separate class module (Chip's method), that I'm not aware of?
I just can't see the point.


Tom,
You keep referring to Chip's page


It's the established way of doing things <g. It takes a lot to work to
successfully challenge deeply held views.

FWIW I agree with you that ThisWorkbook is a fine place to host the
WithEvents Excel.Application object and it too is my preferred
approach. One of the regulars accused me of having bad taste for
suggesting this so seems an emotive subject. IIRC Chip reserves the
ThisWorkbook code module solely for event handlers of the Workbook
events, so at least he is consistent with his methodologies <g.

Personally, I use ThisWorkbook for all properties and methods that need
to be available globally to the workbook (and I'm not talking Public, I
mean Friends). Again, this is not the establishment's way; the crowd
prefer standard modules.

It is my opinion that using a class module to host the WithEvents
Excel.Application object is a bit counterintuitive. Is it encapsulation
for the sake of it? How many instances of this EventClass will there be
in a single project? Always and only one, I fancy. Let's face it: the
only reason it's in a class module at is because the WithEvents keyword
is only supported for class modules. If they could get away with
putting it in a standard module, they would <g.

For many people, this EventClass is their first and only class module
but it isn't really a 'proper' class. It is my opinion that such
'single use' classes can hinder newbies learning the joys of classes,
OOP and all that in VBA.

Don't get me wrong, I'm not antiestablishment (well, maybe a little
<g). Tom and Chip (and others) have helped me grasp the basics but I
never stopped thinking and discovering things for myself. Tom is kind
enough to frequently link to/re-post my code and even Chip has
previously revised his aforementioned page on EventClass after I gave
him some feedback. Yes, they do listen to the likes of us.

As I said, I agree with you but it will take a lot of effort to
challenge this established approach.

Jamie.

--