Scott Beeson once posted the following code here to lauch an application inside an userform:
Public Class Form1
Declare Auto Function SetParent Lib "user32.dll" (ByVal hWndChild As IntPtr, ByVal hWndNewParent As IntPtr) As Integer
Declare Auto Function SendMessage Lib "user32.dll" (ByVal hWnd As IntPtr, ByVal Msg As Integer, ByVal wParam As Integer, ByVal lParam As Integer) As Integer
Private Const WM_SYSCOMMAND As Integer = 274
Private Const SC_MAXIMIZE As Integer = 61488
Dim proc As Process
Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
proc = Process.Start("C:\WINDOWS\notepad.exe")
proc.WaitForInputIdle()
SetParent(proc.MainWindowHandle, Panel1.Handle)
SendMessage(proc.MainWindowHandle, WM_SYSCOMMAND, SC_MAXIMIZE, 0)
Me.BringToFront()
End Sub
End Class
So I've tried to start Excel2007 and it worked, although not always stable. But Excel2010 doesn't open in the userform, just the normal way. I have two questions:
1) Has anyone maybe an idea how to get XL2010 working with this?
2) Any idea how to code this in a WPF mainwindow? 'Panel1.Handle' doesn't seem to exit there...