Instantiation of ActiveX Control from Class Module

Instantiation of ActiveX Control from Class Module

am 02.04.2008 00:44:30 von animedreamer

I am trying to instantiate an activex control directly from a
class module.

My declaration is as follows: Private WithEvents myPCCharge As
Charge.OCXCharge

I am trying to instantiate the object as follows: set
myPCCharge = CreateObject("Charge.OCXCharge")

When the program encounters the line of code above, I receive
the following error: "Run-time error '398': Client Site not
available." I have done some searching on this error message, but it
did not turn up anything substantial. Can anyone give me some ideas
what might be occurring here? Typically, I work with this control by
placing it directly on a form, but I do not understand why the above
would not work equally as well. If I have to, I will place the
control on a form that I can instantiate from my class module, but I
really don't want to do this. Any help is appreciated.

Vincent

Re: Instantiation of ActiveX Control from Class Module

am 02.04.2008 01:52:22 von Stuart McCall

"Vincent" wrote in message
news:cd730673-1920-493c-92ad-7b6b5a622181@8g2000hse.googlegr oups.com...
> I am trying to instantiate an activex control directly from a
> class module.
>
> My declaration is as follows: Private WithEvents myPCCharge As
> Charge.OCXCharge
>
> I am trying to instantiate the object as follows: set
> myPCCharge = CreateObject("Charge.OCXCharge")
>
> When the program encounters the line of code above, I receive
> the following error: "Run-time error '398': Client Site not
> available." I have done some searching on this error message, but it
> did not turn up anything substantial. Can anyone give me some ideas
> what might be occurring here? Typically, I work with this control by
> placing it directly on a form, but I do not understand why the above
> would not work equally as well. If I have to, I will place the
> control on a form that I can instantiate from my class module, but I
> really don't want to do this. Any help is appreciated.
>
> Vincent

If you're going to use late binding (ie CreateObject), then your variable
should be of type Object. The problem with that is that you can't use
WithEvents. Presumably you have a reference set to the OCX. If so, you can
say:

Set myPCCharge = New Charge.OCXCharge

Re: Instantiation of ActiveX Control from Class Module

am 02.04.2008 02:05:04 von animedreamer

On Apr 1, 7:52=A0pm, "Stuart McCall" wrote:
> "Vincent" wrote in message
>
> news:cd730673-1920-493c-92ad-7b6b5a622181@8g2000hse.googlegr oups.com...
>
>
>
>
>
> > =A0 =A0 =A0I am trying to instantiate an activex control directly from a=

> > class module.
>
> > =A0 =A0 My declaration is as follows: =A0Private WithEvents myPCCharge A=
s
> > Charge.OCXCharge
>
> > =A0 =A0 =A0I am trying to instantiate the object as follows: =A0set
> > myPCCharge =3D CreateObject("Charge.OCXCharge")
>
> > =A0 =A0 =A0When the program encounters the line of code above, I receive=

> > the following error: =A0"Run-time error '398': Client Site not
> > available." =A0I have done some searching on this error message, but it
> > did not turn up anything substantial. =A0Can anyone give me some ideas
> > what might be occurring here? =A0Typically, I work with this control by
> > placing it directly on a form, but I do not understand why the above
> > would not work equally as well. =A0If I have to, I will place the
> > control on a form that I can instantiate from my class module, but I
> > really don't want to do this. =A0Any help is appreciated.
>
> > Vincent
>
> If you're going to use late binding (ie CreateObject), then your variable
> should be of type Object. The problem with that is that you can't use
> WithEvents. Presumably you have a reference set to the OCX. If so, you can=

> say:
>
> Set myPCCharge =3D New Charge.OCXCharge- Hide quoted text -
>
> - Show quoted text -

Stuart,

I originally tried to do this, but the compiler barked at me.
The specific error message was "Compile error: Invalid use of New
keyword"

Vincent

Re: Instantiation of ActiveX Control from Class Module

am 02.04.2008 02:40:15 von Stuart McCall

"Vincent" wrote in message
news:854fac08-d269-4a13-af0f-46689e790aa3@y21g2000hsf.google groups.com...
On Apr 1, 7:52 pm, "Stuart McCall" wrote:
> "Vincent" wrote in message
>
> news:cd730673-1920-493c-92ad-7b6b5a622181@8g2000hse.googlegr oups.com...
>
>
>
>
>
> > I am trying to instantiate an activex control directly from a
> > class module.
>
> > My declaration is as follows: Private WithEvents myPCCharge As
> > Charge.OCXCharge
>
> > I am trying to instantiate the object as follows: set
> > myPCCharge = CreateObject("Charge.OCXCharge")
>
> > When the program encounters the line of code above, I receive
> > the following error: "Run-time error '398': Client Site not
> > available." I have done some searching on this error message, but it
> > did not turn up anything substantial. Can anyone give me some ideas
> > what might be occurring here? Typically, I work with this control by
> > placing it directly on a form, but I do not understand why the above
> > would not work equally as well. If I have to, I will place the
> > control on a form that I can instantiate from my class module, but I
> > really don't want to do this. Any help is appreciated.
>
> > Vincent
>
> If you're going to use late binding (ie CreateObject), then your variable
> should be of type Object. The problem with that is that you can't use
> WithEvents. Presumably you have a reference set to the OCX. If so, you can
> say:
>
> Set myPCCharge = New Charge.OCXCharge- Hide quoted text -
>
> - Show quoted text -

Stuart,

I originally tried to do this, but the compiler barked at me.
The specific error message was "Compile error: Invalid use of New
keyword"

Vincent

Ah, then I'm out of ideas, sorry. I haven't worked with OCX's much.

Re: Instantiation of ActiveX Control from Class Module

am 02.04.2008 02:46:57 von Stuart McCall

"Vincent" wrote in message
news:854fac08-d269-4a13-af0f-46689e790aa3@y21g2000hsf.google groups.com...
On Apr 1, 7:52 pm, "Stuart McCall" wrote:
> "Vincent" wrote in message
>
> news:cd730673-1920-493c-92ad-7b6b5a622181@8g2000hse.googlegr oups.com...
>
>
>
>
>
> > I am trying to instantiate an activex control directly from a
> > class module.
>
> > My declaration is as follows: Private WithEvents myPCCharge As
> > Charge.OCXCharge
>
> > I am trying to instantiate the object as follows: set
> > myPCCharge = CreateObject("Charge.OCXCharge")
>
> > When the program encounters the line of code above, I receive
> > the following error: "Run-time error '398': Client Site not
> > available." I have done some searching on this error message, but it
> > did not turn up anything substantial. Can anyone give me some ideas
> > what might be occurring here? Typically, I work with this control by
> > placing it directly on a form, but I do not understand why the above
> > would not work equally as well. If I have to, I will place the
> > control on a form that I can instantiate from my class module, but I
> > really don't want to do this. Any help is appreciated.
>
> > Vincent
>
> If you're going to use late binding (ie CreateObject), then your variable
> should be of type Object. The problem with that is that you can't use
> WithEvents. Presumably you have a reference set to the OCX. If so, you can
> say:
>
> Set myPCCharge = New Charge.OCXCharge- Hide quoted text -
>
> - Show quoted text -

Stuart,

I originally tried to do this, but the compiler barked at me.
The specific error message was "Compile error: Invalid use of New
keyword"

Vincent

Do you have a reference set to the OCX? As in Tools -> References in the
VBE. I haven't worked with OCX's much, but as I understand it, so long as
you don't need it's UI (if any), an OCX can be treated as a com dll. My
memory's a bit vague on the subject, so I could be completely wrong. If
that's the case, then I'm out of ideas, sorry.

Re: Instantiation of ActiveX Control from Class Module

am 02.04.2008 03:09:41 von animedreamer

On Apr 1, 8:46=A0pm, "Stuart McCall" wrote:
> "Vincent" wrote in message
>
> news:854fac08-d269-4a13-af0f-46689e790aa3@y21g2000hsf.google groups.com...
> On Apr 1, 7:52 pm, "Stuart McCall" wrote:
>
>
>
>
>
> > "Vincent" wrote in message
>
> >news:cd730673-1920-493c-92ad-7b6b5a622181@8g2000hse.googleg roups.com...
>
> > > I am trying to instantiate an activex control directly from a
> > > class module.
>
> > > My declaration is as follows: Private WithEvents myPCCharge As
> > > Charge.OCXCharge
>
> > > I am trying to instantiate the object as follows: set
> > > myPCCharge =3D CreateObject("Charge.OCXCharge")
>
> > > When the program encounters the line of code above, I receive
> > > the following error: "Run-time error '398': Client Site not
> > > available." I have done some searching on this error message, but it
> > > did not turn up anything substantial. Can anyone give me some ideas
> > > what might be occurring here? Typically, I work with this control by
> > > placing it directly on a form, but I do not understand why the above
> > > would not work equally as well. If I have to, I will place the
> > > control on a form that I can instantiate from my class module, but I
> > > really don't want to do this. Any help is appreciated.
>
> > > Vincent
>
> > If you're going to use late binding (ie CreateObject), then your variabl=
e
> > should be of type Object. The problem with that is that you can't use
> > WithEvents. Presumably you have a reference set to the OCX. If so, you c=
an
> > say:
>
> > Set myPCCharge =3D New Charge.OCXCharge- Hide quoted text -
>
> > - Show quoted text -
>
> Stuart,
>
> =A0 =A0 =A0 I originally tried to do this, but the compiler barked at me.
> The specific error message was "Compile error: =A0Invalid use of New
> keyword"
>
> Vincent
>
> Do you have a reference set to the OCX? As in Tools -> References in the
> VBE. I haven't worked with OCX's much, but as I understand it, so long as
> you don't need it's UI (if any), an OCX can be treated as a com dll. My
> memory's a bit vague on the subject, so I could be completely wrong. If
> that's the case, then I'm out of ideas, sorry.- Hide quoted text -
>
> - Show quoted text -

Stuart,

Yes, there is a reference to the ocx.

Vincent

Re: Instantiation of ActiveX Control from Class Module

am 02.04.2008 03:38:34 von Stuart McCall

"Vincent" wrote in message
news:2afd71ee-753e-472a-8f69-a17b7bcaab26@m36g2000hse.google groups.com...
On Apr 1, 8:46 pm, "Stuart McCall" wrote:
> "Vincent" wrote in message
>
> news:854fac08-d269-4a13-af0f-46689e790aa3@y21g2000hsf.google groups.com...
> On Apr 1, 7:52 pm, "Stuart McCall" wrote:
>
>
>
>
>
> > "Vincent" wrote in message
>
> >news:cd730673-1920-493c-92ad-7b6b5a622181@8g2000hse.googleg roups.com...
>
> > > I am trying to instantiate an activex control directly from a
> > > class module.
>
> > > My declaration is as follows: Private WithEvents myPCCharge As
> > > Charge.OCXCharge
>
> > > I am trying to instantiate the object as follows: set
> > > myPCCharge = CreateObject("Charge.OCXCharge")
>
> > > When the program encounters the line of code above, I receive
> > > the following error: "Run-time error '398': Client Site not
> > > available." I have done some searching on this error message, but it
> > > did not turn up anything substantial. Can anyone give me some ideas
> > > what might be occurring here? Typically, I work with this control by
> > > placing it directly on a form, but I do not understand why the above
> > > would not work equally as well. If I have to, I will place the
> > > control on a form that I can instantiate from my class module, but I
> > > really don't want to do this. Any help is appreciated.
>
> > > Vincent
>
> > If you're going to use late binding (ie CreateObject), then your
> > variable
> > should be of type Object. The problem with that is that you can't use
> > WithEvents. Presumably you have a reference set to the OCX. If so, you
> > can
> > say:
>
> > Set myPCCharge = New Charge.OCXCharge- Hide quoted text -
>
> > - Show quoted text -
>
> Stuart,
>
> I originally tried to do this, but the compiler barked at me.
> The specific error message was "Compile error: Invalid use of New
> keyword"
>
> Vincent
>
> Do you have a reference set to the OCX? As in Tools -> References in the
> VBE. I haven't worked with OCX's much, but as I understand it, so long as
> you don't need it's UI (if any), an OCX can be treated as a com dll. My
> memory's a bit vague on the subject, so I could be completely wrong. If
> that's the case, then I'm out of ideas, sorry.- Hide quoted text -
>
> - Show quoted text -

Stuart,

Yes, there is a reference to the ocx.

Vincent

Take a look at this thread I found:

http://www.developersdex.com/vb/message.asp?p=640&r=5861401& page=2

The guys are discussing vb6 code but I think there's a lot of good info to
be gleaned here (and in some of the links).

HTH

Re: Instantiation of ActiveX Control from Class Module

am 02.04.2008 03:47:22 von rkc

Vincent wrote:
> On Apr 1, 8:46 pm, "Stuart McCall" wrote:
>> "Vincent" wrote in message
>>
>> news:854fac08-d269-4a13-af0f-46689e790aa3@y21g2000hsf.google groups.com...
>> On Apr 1, 7:52 pm, "Stuart McCall" wrote:
>>
>>
>>
>>
>>
>>> "Vincent" wrote in message
>>> news:cd730673-1920-493c-92ad-7b6b5a622181@8g2000hse.googlegr oups.com...
>>>> I am trying to instantiate an activex control directly from a
>>>> class module.
>>>> My declaration is as follows: Private WithEvents myPCCharge As
>>>> Charge.OCXCharge
>>>> I am trying to instantiate the object as follows: set
>>>> myPCCharge = CreateObject("Charge.OCXCharge")
>>>> When the program encounters the line of code above, I receive
>>>> the following error: "Run-time error '398': Client Site not
>>>> available." I have done some searching on this error message, but it
>>>> did not turn up anything substantial. Can anyone give me some ideas
>>>> what might be occurring here? Typically, I work with this control by
>>>> placing it directly on a form, but I do not understand why the above
>>>> would not work equally as well. If I have to, I will place the
>>>> control on a form that I can instantiate from my class module, but I
>>>> really don't want to do this. Any help is appreciated.
>>>> Vincent
>>> If you're going to use late binding (ie CreateObject), then your variable
>>> should be of type Object. The problem with that is that you can't use
>>> WithEvents. Presumably you have a reference set to the OCX. If so, you can
>>> say:
>>> Set myPCCharge = New Charge.OCXCharge- Hide quoted text -
>>> - Show quoted text -
>> Stuart,
>>
>> I originally tried to do this, but the compiler barked at me.
>> The specific error message was "Compile error: Invalid use of New
>> keyword"
>>
>> Vincent
>>
>> Do you have a reference set to the OCX? As in Tools -> References in the
>> VBE. I haven't worked with OCX's much, but as I understand it, so long as
>> you don't need it's UI (if any), an OCX can be treated as a com dll. My
>> memory's a bit vague on the subject, so I could be completely wrong. If
>> that's the case, then I'm out of ideas, sorry.- Hide quoted text -
>>
>> - Show quoted text -
>
> Stuart,
>
> Yes, there is a reference to the ocx.

What does it appear as in the object browser?

Re: Instantiation of ActiveX Control from Class Module

am 02.04.2008 05:01:34 von animedreamer

On Apr 1, 9:47=A0pm, rkc wrote:
> Vincent wrote:
> > On Apr 1, 8:46 pm, "Stuart McCall" wrote:
> >> "Vincent" wrote in message
>
> >>news:854fac08-d269-4a13-af0f-46689e790aa3@y21g2000hsf.goog legroups.com..=
..
> >> On Apr 1, 7:52 pm, "Stuart McCall" wrote:
>
> >>> "Vincent" wrote in message
> >>>news:cd730673-1920-493c-92ad-7b6b5a622181@8g2000hse.googl egroups.com...=

> >>>> I am trying to instantiate an activex control directly from a
> >>>> class module.
> >>>> My declaration is as follows: Private WithEvents myPCCharge As
> >>>> Charge.OCXCharge
> >>>> I am trying to instantiate the object as follows: set
> >>>> myPCCharge =3D CreateObject("Charge.OCXCharge")
> >>>> When the program encounters the line of code above, I receive
> >>>> the following error: "Run-time error '398': Client Site not
> >>>> available." I have done some searching on this error message, but it
> >>>> did not turn up anything substantial. Can anyone give me some ideas
> >>>> what might be occurring here? Typically, I work with this control by
> >>>> placing it directly on a form, but I do not understand why the above
> >>>> would not work equally as well. If I have to, I will place the
> >>>> control on a form that I can instantiate from my class module, but I
> >>>> really don't want to do this. Any help is appreciated.
> >>>> Vincent
> >>> If you're going to use late binding (ie CreateObject), then your varia=
ble
> >>> should be of type Object. The problem with that is that you can't use
> >>> WithEvents. Presumably you have a reference set to the OCX. If so, you=
can
> >>> say:
> >>> Set myPCCharge =3D New Charge.OCXCharge- Hide quoted text -
> >>> - Show quoted text -
> >> Stuart,
>
> >> =A0 =A0 =A0 I originally tried to do this, but the compiler barked at m=
e.
> >> The specific error message was "Compile error: =A0Invalid use of New
> >> keyword"
>
> >> Vincent
>
> >> Do you have a reference set to the OCX? As in Tools -> References in th=
e
> >> VBE. I haven't worked with OCX's much, but as I understand it, so long =
as
> >> you don't need it's UI (if any), an OCX can be treated as a com dll. My=

> >> memory's a bit vague on the subject, so I could be completely wrong. If=

> >> that's the case, then I'm out of ideas, sorry.- Hide quoted text -
>
> >> - Show quoted text -
>
> > Stuart,
>
> > =A0 =A0 =A0 Yes, there is a reference to the ocx.
>
> What does it appear as in the object browser?- Hide quoted text -
>
> - Show quoted text -

I'm not entirely sure what you mean. If I open the object
browser and select the Charge library, there is an OCXCharge object
listed.

Vincent

Re: Instantiation of ActiveX Control from Class Module

am 03.04.2008 16:11:01 von animedreamer

On Apr 1, 11:01=A0pm, Vincent wrote:
> On Apr 1, 9:47=A0pm, rkc wrote:
>
>
>
>
>
> > Vincent wrote:
> > > On Apr 1, 8:46 pm, "Stuart McCall" wrote:
> > >> "Vincent" wrote in message
>
> > >>news:854fac08-d269-4a13-af0f-46689e790aa3@y21g2000hsf.goog legroups.com=
....
> > >> On Apr 1, 7:52 pm, "Stuart McCall" wrote:
>
> > >>> "Vincent" wrote in message
> > >>>news:cd730673-1920-493c-92ad-7b6b5a622181@8g2000hse.googl egroups.com.=
...
> > >>>> I am trying to instantiate an activex control directly from a
> > >>>> class module.
> > >>>> My declaration is as follows: Private WithEvents myPCCharge As
> > >>>> Charge.OCXCharge
> > >>>> I am trying to instantiate the object as follows: set
> > >>>> myPCCharge =3D CreateObject("Charge.OCXCharge")
> > >>>> When the program encounters the line of code above, I receive
> > >>>> the following error: "Run-time error '398':ClientSitenot
> > >>>>available." I have done some searching on this error message, but it=

> > >>>> didnotturn up anything substantial. Can anyone give me some ideas
> > >>>> what might be occurring here? Typically, I work with this control b=
y
> > >>>> placing it directly on a form, but I donotunderstand why the above
> > >>>> wouldnotwork equally as well. If I have to, I will place the
> > >>>> control on a form that I can instantiate from my class module, but =
I
> > >>>> really don't want to do this. Any help is appreciated.
> > >>>> Vincent
> > >>> If you're going to use late binding (ie CreateObject), then your var=
iable
> > >>> should be of type Object. The problem with that is that you can't us=
e
> > >>> WithEvents. Presumably you have a reference set to the OCX. If so, y=
ou can
> > >>> say:
> > >>> Set myPCCharge =3D New Charge.OCXCharge- Hide quoted text -
> > >>> - Show quoted text -
> > >> Stuart,
>
> > >> =A0 =A0 =A0 I originally tried to do this, but the compiler barked at=
me.
> > >> The specific error message was "Compile error: =A0Invalid use of New
> > >> keyword"
>
> > >> Vincent
>
> > >> Do you have a reference set to the OCX? As in Tools -> References in =
the
> > >> VBE. I haven't worked with OCX's much, but as I understand it, so lon=
g as
> > >> you don't need it's UI (if any), an OCX can be treated as a com dll. =
My
> > >> memory's a bit vague on the subject, so I could be completely wrong. =
If
> > >> that's the case, then I'm out of ideas, sorry.- Hide quoted text -
>
> > >> - Show quoted text -
>
> > > Stuart,
>
> > > =A0 =A0 =A0 Yes, there is a reference to the ocx.
>
> > What does it appear as in the object browser?- Hide quoted text -
>
> > - Show quoted text -
>
> =A0 =A0 =A0 I'mnotentirely sure what you mean. =A0If I open the object
> browser and select the Charge library, there is an OCXCharge object
> listed.
>
> Vincent- Hide quoted text -
>
> - Show quoted text -

I'm stumped. Does anyone have any more ideas? Thanks.