View Single Post
  #3   Report Post  
Posted to microsoft.public.excel.programming
Rob Bovey Rob Bovey is offline
external usenet poster
 
Posts: 811
Default Instancing on Classmodule on Excel 2002

"Tetsuya Oguma" <Tetsuya wrote in message
...
I found Instancing on ClassModule that you can set it either "Private" (I
think this is default and used it as you have been using) or
"PublicNotCreatable". Can anyone tell me how to use each case? I cannot

see
any documentation on this on MSDN. Also, I have this sneaky suspicion that

I
have seen this somewhere else, not on VB6 but somewhere...


Hi Tetsuya,

Private and PublicNotCreatable are the only two instancing types
supported in Excel VBA. VB6 has these instancing types as well as four
others (depending on what type of project you are creating). In Excel VBA
the meaning of these instancing types is the following:

Private - Classes of this type are not visible outside the project where
they are located. This is the only instancing type available to classes such
as UserForms. This means there is no way to reference this type of class
from another workbook.

PublicNotCreatable - Classes of this type can be "seen" by other projects if
you set a reference to the project containing the class using the VBE
Tools/References dialog. This means you can declare a variable of this class
type in another project but you cannot create an instance of the class in an
outside project. The project containing the class must provide a function or
subroutine located in a standard module that creates an instance of the
class and passes that instance to other projects via a function return value
or ByRef subroutine argument.

--
Rob Bovey, MCSE, MCSD, Excel MVP
Application Professionals
http://www.appspro.com/

* Please post all replies to this newsgroup *
* I delete all unsolicited e-mail responses *