Why does Excel not want to open within a panel?

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • Thorsun

    #1

    Why does Excel not want to open within a panel?

    It takes a lot for me to give up on finding the solution and for this I've finally reached that point. I have a program that opens a few other programs (PowerPoint, Excel and mIRC) and runs each one inside a panel on the form. I'm having no issues with PowerPoint or mIRC. Excel was working for a bit and now just doesn't work. Here is my code:

    Code:
    Private Const WM_SYSCOMMAND As Integer = 274
    Private Const SC_MAXIMIZED As Integer = 61488
    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 IParam As Integer) As Integer
    Dim proc3 As System.Diagnostics.Process
    
    Private Sub LoadTracker()
    
      proc3 = System.Diagnostics.Process.Start(NameOfMyExcelFile)
      proc3.WaitForInputIdle()
      SetParent(proc3.MainWindowHandle, Me.TPanel.Handle)
      SendMessage(proc3.MainWindowHandle, WM_SYSCOMMAND, SC_MAXIMIZE, 0)
    
    End Sub
    I have a button on the form which launches LoadTracker.
  • Thorsun

    #2
    Yes, I do realize I wrote SC_MAXIMIZED in the Private Const line and then have it as SC_MAXIMIZE below that. It was right in the actual code.

    Anyway I figured it out. I had the SetParent line and the SendMessage line swapped. I put them back in the right order and it worked again.

    Comment

    Working...