Hi Patrick,
I've not yet used the following for a .NET-based solution but it works well
in classic COM Add-ins and with Excel.
'Declare the following API in a module:
Public Declare Function FindWindow Lib "user32.dll" _
Alias "FindWindowA" _
(ByVal lpClassName As String, _
ByVal lpWindowName As String) As Long
Public Declare Function SetWindowLong Lib "user32.dll" _
Alias "SetWindowLongA" ( _
ByVal hwnd As Long, _
ByVal nIndex As Long, _
ByVal dwNewLong As Long) As Long
'Declare the following variables as well:
Public Const CONST_HWIND As Long = -8
Public CONST_XLWIND As Long
In the OnConnection event add the following:
'Here we grab the Main window for Excel.
CONST_XLWIND = FindWindow(vbNullString, xlApp.Caption)
'In a function or Sub that load and show the form add the following:
Load frmE
SetWindowLong frmE.hwnd, CONST_HWIND, CONST_XLWIND
frmE.Show vbModeless
'frmE refer to the actual form we target.
Please test the above and let me know if it works with .NET as well.
---------------
With kind regards,
Dennis
Weekly Blog .NET & Excel:
http://xldennis.wordpress.com/
My English site:
http://www.excelkb.com/default.aspx
My Swedish site:
http://www.xldennis.com/