From: RB Smissaert on
Have an ActiveX dll compiled with VB6.
It simply is some code that loads a VB form in Excel and this works very
well.
The trouble is I get an error 429 runtime error, ActiveX component can't
create object
when the dll is first used to load the form.

The strange thing is that another .dll file that was compiled a bit earlier
runs fine, despite
there being no substantial difference in the code, only some very minor
adjustments to the
the controls in the form. This file has the same name and I copied it to the
same location,
overwriting the trouble-some file.
I think it somehow has to do with the registration of the dll in the
registry, but I can't pinpoint
the exact problem.

Thanks for any advice with this.


RBS

From: RB Smissaert on
Maybe it helps to see the relevant bits of code.

In Excel:
------------------

Dim clsRCB As RCBrowser.clsRCBrowser
Set clsRCB = New RCBrowser.clsRCBrowser
Set clsRCB.ExcelApp = Application
clsRCB.ShowVB6Form 'ERROR OCCURS HERE
Set clsRCB = Nothing

In the VB6 class module:
------------------------------------

Private Const GWL_HWNDPARENT As Long = -8
Private mxlApp As Excel.Application
Private mlXLhWnd As Long
Private Declare Function FindWindow _
Lib "user32" _
Alias "FindWindowA" _
(ByVal lpClassName As String, _
ByVal lpWindowName As String) As Long
Private Declare Function SetWindowLong _
Lib "user32" _
Alias "SetWindowLongA" _
(ByVal hWnd As Long, _
ByVal nIndex As Long, _
ByVal dwNewLong As Long) As Long

Public Property Set ExcelApp(ByRef xlApp As Excel.Application)
Set mxlApp = xlApp
mlXLhWnd = FindWindow(vbNullString, mxlApp.Caption)
End Property

Public Sub ShowVB6Form()
Set frmRCB = New frmRCBrowser
Load frmRCB
SetWindowLong frmRCB.hWnd, GWL_HWNDPARENT, mlXLhWnd
frmRCB.Show 0
End Sub

frmRCB is declared Public in a normal VB6 module.

I deleted all the keys in the registry pointing to the dll, but it made no
difference, except
I get first runtime error 5, Invalid procedure call or argument, and then
runtime error 440,
automation error. It points to the same line in Excel though as shown above.
Both these error messages (5 and 440) are generated by VB6.

Again, any advice greatly appreciated.


RBS


"RB Smissaert" <bartsmissaert(a)blueyonder.co.uk> wrote in message
news:%23CxMcCiaFHA.2076(a)TK2MSFTNGP15.phx.gbl...
> Have an ActiveX dll compiled with VB6.
> It simply is some code that loads a VB form in Excel and this works very
> well.
> The trouble is I get an error 429 runtime error, ActiveX component can't
> create object
> when the dll is first used to load the form.
>
> The strange thing is that another .dll file that was compiled a bit
> earlier runs fine, despite
> there being no substantial difference in the code, only some very minor
> adjustments to the
> the controls in the form. This file has the same name and I copied it to
> the same location,
> overwriting the trouble-some file.
> I think it somehow has to do with the registration of the dll in the
> registry, but I can't pinpoint
> the exact problem.
>
> Thanks for any advice with this.
>
>
> RBS

From: Ken Halter on
"RB Smissaert" <bartsmissaert(a)blueyonder.co.uk> wrote in message
news:eKiCjOiaFHA.2884(a)tk2msftngp13.phx.gbl...
> Maybe it helps to see the relevant bits of code.
>
>
> Public Sub ShowVB6Form()
> Set frmRCB = New frmRCBrowser
> Load frmRCB

In Form_Load, do you have any calls to SetFocus? If so, that's where the
error 5's coming from.

> SetWindowLong frmRCB.hWnd, GWL_HWNDPARENT, mlXLhWnd
> frmRCB.Show vbModeless 'using the constant makes it easier to read.
> End Sub

Are you using Binary Compatibility? If not, that may be where the error
440's coming from.


--
Ken Halter - MS-MVP-VB - http://www.vbsight.com
DLL Hell problems? Try ComGuard - http://www.vbsight.com/ComGuard.htm
Please keep all discussions in the groups..


From: bart.smissaert on
Ken,

Thanks for that.
I am at work now, so can't see the code, but I don't think either of
your suggestions applies. I think I know where the problem is and will
report back when I am sure and have it fixed.

RBS

Ken Halter wrote:
> "RB Smissaert" <bartsmissaert(a)blueyonder.co.uk> wrote in message
> news:eKiCjOiaFHA.2884(a)tk2msftngp13.phx.gbl...
> > Maybe it helps to see the relevant bits of code.
> >
> >
> > Public Sub ShowVB6Form()
> > Set frmRCB = New frmRCBrowser
> > Load frmRCB
>
> In Form_Load, do you have any calls to SetFocus? If so, that's where the
> error 5's coming from.
>
> > SetWindowLong frmRCB.hWnd, GWL_HWNDPARENT, mlXLhWnd
> > frmRCB.Show vbModeless 'using the constant makes it easier to read.
> > End Sub
>
> Are you using Binary Compatibility? If not, that may be where the error
> 440's coming from.
>
>
> --
> Ken Halter - MS-MVP-VB - http://www.vbsight.com
> DLL Hell problems? Try ComGuard - http://www.vbsight.com/ComGuard.htm
> Please keep all discussions in the groups..

From: RB Smissaert on
> In Form_Load, do you have any calls to SetFocus? If so, that's where the
> error 5's coming from.

Spot on.
That was exactly the problem and all solved now.

RBS


"Ken Halter" <Ken_Halter(a)Use_Sparingly_Hotmail.com> wrote in message
news:uSBavKqaFHA.2496(a)TK2MSFTNGP14.phx.gbl...
> "RB Smissaert" <bartsmissaert(a)blueyonder.co.uk> wrote in message
> news:eKiCjOiaFHA.2884(a)tk2msftngp13.phx.gbl...
>> Maybe it helps to see the relevant bits of code.
>>
>>
>> Public Sub ShowVB6Form()
>> Set frmRCB = New frmRCBrowser
>> Load frmRCB
>
> In Form_Load, do you have any calls to SetFocus? If so, that's where the
> error 5's coming from.
>
>> SetWindowLong frmRCB.hWnd, GWL_HWNDPARENT, mlXLhWnd
>> frmRCB.Show vbModeless 'using the constant makes it easier to read.
>> End Sub
>
> Are you using Binary Compatibility? If not, that may be where the error
> 440's coming from.
>
>
> --
> Ken Halter - MS-MVP-VB - http://www.vbsight.com
> DLL Hell problems? Try ComGuard - http://www.vbsight.com/ComGuard.htm
> Please keep all discussions in the groups..
>