Referencing Userform in VB6

A

avi

Hello,

I have a userform in Excel ith some controls and activeXs on it

Is there a way to reference the controls and the userform from VB6?

Excel has not a Userform property...

Thanks
Avi
 
H

Harald Staff

Hi Avi

The office userform and its controls are in the "Forms2" library.

HTH. Best wishes Harald
 
G

GS

avi has brought this to us :
Hello,

I have a userform in Excel ith some controls and activeXs on it

Is there a way to reference the controls and the userform from VB6?

Excel has not a Userform property...

Thanks
Avi

Not enough info! It depends where you have this userform, how you want
to access it, and why you want to access it from VB6 rather than VBA
within Excel. If you more fully explain what you're trying to do then
better help can be provided.
 
P

Peter T

As others have implied it's very difficult to answer a question like this
without so little information. But FWIW you can use your Excel VBA userform
in your VB6 app, providing it's for use with an Office app, say as an
ActiveX dll for use with Excel.

Regards,
Peter T
 
A

avi

Thanks everyone

I have a VBA application with some controls on UserForm1 of ActiveX
type, lets say CircleGauge1, CircleGauge2...

I want to be able to manipulate the controls property when the
Userform is in run mode, for example changing the color of
CircleGauge1

In order to it from VB6, I need that my VB6 program ( a dll) knows how
to refer to UserForm1 and to its controls. The VB6 dll is referenced
in Excel VBA

Thanks
Avi
 
P

Peter T

Pass a reference to the form from the Excel project to the dll.

' in Excel
dim frm as userform1
set frm = new userform1
set gVB6cls = new myVB6App.myClass

Set gVB6cls.objFrm = frm ' Public objFrm as Object
frm.show

Or maybe declare gVB6cls in the form and in the form's initialize event
set gVB6cls = new myVB6App.myClass
Set gVB6cls.objFrm = Me

In the myVB6App.myClass's initialize event set a global reference to self,
eg
Set gCls = Me

Also include something like this
Public Sub Bye()
' be sure to call this externally before destroying the class
set gCls = nothing
end sub

Now anywhere in your VB6 app you can refer to gCls.objFrm and
gCls.objFrm.myControl

In the form's unload event first call gVB6cls.Bye
then
Set gVB6cls = nothing

FWIW you can start your Excel form from VB6 using xlApp.Run, say to call a
procedure to load the userform and do the above.

Instead of passing the userform, objFrm, maybe it might be better to pass
references to the controls you know you will want to handle in the VB6 app.
In the VB6 you can't do -
Dim objFrm as Userform1
but you might be able to do
Dim myCtrl as ControlType ' ie early binding

Regards,
Peter T
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top