Private Declare Function SetParent Lib "user32.dll" (ByVal hWndChild As Long, ByVal hWndNewParent As Long) As Long Private Declare Function FindWindowEx Lib "user32.dll" Alias "FindWindowExA" (ByVal hWnd1 As Long, ByVal hWnd2 As Long, ByVal lpsz1 As String, ByVal lpsz2 As String) As Long Private moExcel As Excel.Application Private moWorkBook As Workbook Private mhDeskWnd As Long Private mhDeskParentWnd As Long Private Sub Form_Load() Set moExcel = New Excel.Application moExcel.Visible = True Set moWorkBook = moExcel.Workbooks.Open("D:\Documents and Settings\THOM31R.DOM\Mes documents\Fiches de temps\Fiche de temps - 2007-02.xls") mhDeskWnd = FindWindowEx(moWorkBook.Application.hwnd, 0, "XLDESK", vbNullString) If mhDeskWnd Then mhDeskParentWnd = SetParent(mhDeskWnd, Me.hwnd) Else MsgBox "Fenetre XLDESK non trouvée" End If End Sub Private Sub Form_QueryUnload(Cancel As Integer, UnloadMode As Integer) SetParent mhDeskWnd, mhDeskParentWnd moWorkBook.Close False moExcel.Quit End Sub
Public Declare Function SetParent Lib "user32" (ByVal hWndChild As Long, ByVal hWndNewParent As Long) As Long Public Declare Function FindWindow Lib "user32" Alias "FindWindowA" (ByVal lpClassName As String, ByVal lpWindowName As String) As Long
Vous n’avez pas trouvé la réponse que vous recherchez ?
Posez votre question