ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Public oMyClass As New MyProject.MyClass (https://www.excelbanter.com/excel-programming/405713-public-omyclass-new-myproject-myclass.html)

OfficeUser

Public oMyClass As New MyProject.MyClass
 
I have an .ocx file named MyProject. It contains a class named MyClass which
contains two VBA functions. MyProject is referenced in Tools-References.
Where do I put this line of code:
Public oMyClass As New MyProject.MyClass
so the following occurs:
Anywhere in your Code you should now be able (supported by intellisense), to
type oMyClass. .... and as soon as you type that, your list of functions
inside MyClass should pop up and be usable inside VBA.



Chip Pearson

Public oMyClass As New MyProject.MyClass
 
Make sure that MyClass is Public and creatable. Then, you should be able to
put the declaration in the "Declarations" section of a code module (NOT an
object module like a class or ThisWorkbook), outside of and before any proc
in that module.


--
Cordially,
Chip Pearson
Microsoft Most Valuable Professional
Excel Product Group, 1998 - 2008
Pearson Software Consulting, LLC
www.cpearson.com
(email on web site)

"OfficeUser" wrote in message
...
I have an .ocx file named MyProject. It contains a class named MyClass
which contains two VBA functions. MyProject is referenced in
Tools-References. Where do I put this line of code:
Public oMyClass As New MyProject.MyClass
so the following occurs:
Anywhere in your Code you should now be able (supported by intellisense),
to type oMyClass. .... and as soon as you type that, your list of
functions inside MyClass should pop up and be usable inside VBA.



OfficeUser

Public oMyClass As New MyProject.MyClass
 
Thanks for responding, Chip!

What do you mean by "Make sure that MyClass is Public and creatable"? How do
I do that?

Thanks!



"Chip Pearson" wrote in message
...
Make sure that MyClass is Public and creatable. Then, you should be able
to put the declaration in the "Declarations" section of a code module (NOT
an object module like a class or ThisWorkbook), outside of and before any
proc in that module.


--
Cordially,
Chip Pearson
Microsoft Most Valuable Professional
Excel Product Group, 1998 - 2008
Pearson Software Consulting, LLC
www.cpearson.com
(email on web site)

"OfficeUser" wrote in message
...
I have an .ocx file named MyProject. It contains a class named MyClass
which contains two VBA functions. MyProject is referenced in
Tools-References. Where do I put this line of code:
Public oMyClass As New MyProject.MyClass
so the following occurs:
Anywhere in your Code you should now be able (supported by intellisense),
to type oMyClass. .... and as soon as you type that, your list of
functions inside MyClass should pop up and be usable inside VBA.





Chip Pearson

Public oMyClass As New MyProject.MyClass
 
It is the Instancing property (accessible in the Properties window of VB) of
the class. The property can be Private, PublicNotCreatable, MultiUse or
Global MultiUse. You want to make sure that it is not Private or
PublicNotCreatable.


--
Cordially,
Chip Pearson
Microsoft Most Valuable Professional
Excel Product Group, 1998 - 2008
Pearson Software Consulting, LLC
www.cpearson.com
(email on web site)


"OfficeUser" wrote in message
...
Thanks for responding, Chip!

What do you mean by "Make sure that MyClass is Public and creatable"? How
do I do that?

Thanks!



"Chip Pearson" wrote in message
...
Make sure that MyClass is Public and creatable. Then, you should be able
to put the declaration in the "Declarations" section of a code module
(NOT an object module like a class or ThisWorkbook), outside of and
before any proc in that module.


--
Cordially,
Chip Pearson
Microsoft Most Valuable Professional
Excel Product Group, 1998 - 2008
Pearson Software Consulting, LLC
www.cpearson.com
(email on web site)

"OfficeUser" wrote in message
...
I have an .ocx file named MyProject. It contains a class named MyClass
which contains two VBA functions. MyProject is referenced in
Tools-References. Where do I put this line of code:
Public oMyClass As New MyProject.MyClass
so the following occurs:
Anywhere in your Code you should now be able (supported by
intellisense), to type oMyClass. .... and as soon as you type that, your
list of functions inside MyClass should pop up and be usable inside VBA.






OfficeUser

Public oMyClass As New MyProject.MyClass
 
Thanks, Chip!

BTW, I read a lot of the threads here and see you responding to a goodly
number if questions. You are always very courteous and professional. I like
how you end all your responses with "Cordially"!!

Thanks for all the time you put into this newsgroup.


"Chip Pearson" wrote in message
...
It is the Instancing property (accessible in the Properties window of VB)
of the class. The property can be Private, PublicNotCreatable, MultiUse or
Global MultiUse. You want to make sure that it is not Private or
PublicNotCreatable.


--
Cordially,
Chip Pearson
Microsoft Most Valuable Professional
Excel Product Group, 1998 - 2008
Pearson Software Consulting, LLC
www.cpearson.com
(email on web site)


"OfficeUser" wrote in message
...
Thanks for responding, Chip!

What do you mean by "Make sure that MyClass is Public and creatable"? How
do I do that?

Thanks!



"Chip Pearson" wrote in message
...
Make sure that MyClass is Public and creatable. Then, you should be able
to put the declaration in the "Declarations" section of a code module
(NOT an object module like a class or ThisWorkbook), outside of and
before any proc in that module.


--
Cordially,
Chip Pearson
Microsoft Most Valuable Professional
Excel Product Group, 1998 - 2008
Pearson Software Consulting, LLC
www.cpearson.com
(email on web site)

"OfficeUser" wrote in message
...
I have an .ocx file named MyProject. It contains a class named MyClass
which contains two VBA functions. MyProject is referenced in
Tools-References. Where do I put this line of code:
Public oMyClass As New MyProject.MyClass
so the following occurs:
Anywhere in your Code you should now be able (supported by
intellisense), to type oMyClass. .... and as soon as you type that,
your list of functions inside MyClass should pop up and be usable
inside VBA.









All times are GMT +1. The time now is 10:44 AM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com