////In Activex Class module i have the following code
Option Explicit
'Class constant declarations follows
'SetWindowLongA API constant
Private Const GWL_HWNDPARENT As Long = -8
'Object reference to the calling Excel Application
Private mXlApp As Excel.Application
Private mlXLhWnd As Long
'Class DLL Declarations
Private Declare Function FindWindowA Lib "user32" _
(ByVal lpClassName As String, _
ByVal lpWindowName As String) As Long
Private Declare Function SetWindowLongA Lib "user32" _
(ByVal hWnd As Long, ByVal nIndex As Long, _
ByVal dwNewLong As Long) As Long
'Class property procedures
Public Property Set ExcelApp(ByRef XlApp As Excel.Application)
Set mXlApp = XlApp
'Get the window handle of the excel application as soon as it passed
mlXLhWnd = FindWindowA(vbNullString, mXlApp.Caption)
End Property
'Class Event Procedure
Private Sub Class_Terminate()
Set mXlApp = Nothing
End Sub
Public Sub ShowForm()
Dim frmform As Form1
Set frmform = New Form1
Load frmform
'parent the form window to the excel application window
SetWindowLongA frmform.hWnd, GWL_HWNDPARENT, mlXLhWnd
frmform.Show vbModal
Unload frmform
Set frmform = Nothing
End Sub
///in Form ActivexDll i have a command button
sub commandbutton1_click
unload form1
form1.hide
end sub
///in excel button i have
sub MyVb6Form_Click
Dim clsform As project1.Class1
Set clsform = New project1.Class1
Set clsform .ExcelApp = Application
clsform .ShowForm
Set clsform = Nothing
end sub
Main Topics
Browse All Topics





by: Julian_KPosted on 2006-10-09 at 07:56:39ID: 17690978
Hi :)
Can you post some code, the part where you call your form, and where closing it?
Are there one or more other forms that are referenced by the called form?
Regards,
Julian