1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26
| Imports Office = Microsoft.Office.Core
Imports Excel = Microsoft.Office.Interop.Excel
Public Class View
Dim FichierSource As String = Application.StartupPath & "\TEST.xls" 'Nom de ton fichier Excel
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
Private Sub View_Load(sender As Object, e As EventArgs) Handles MyBase.Load
Dim sExcelFileName = FichierSource
Dim oExcel As New Excel.Application
oExcel.DisplayAlerts = False
oExcel.Workbooks.Open(sExcelFileName, ReadOnly:=False)
oExcel.Application.WindowState = Excel.XlWindowState.xlNormal
oExcel.Visible = True
SetParent(oExcel.Hwnd, pnlExcel.Handle)
SendMessage(oExcel.Hwnd, WM_SYSCOMMAND, SC_MAXIMIZE, 0)
End Sub
End Class |
Partager