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 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44
|
Option Explicit On
Option Strict On
Imports Microsoft.Office.Interop
Imports System
Imports System.ComponentModel
Imports System.Drawing
Imports System.Runtime.InteropServices
Imports System.Text
Imports System.Windows.Forms
Imports Microsoft.Office.Interop.Excel
Public Class Form1
Dim Xlsheet As Microsoft.Office.Interop.Excel.Worksheet
'Fonction ouvrir Fichier
Private Sub OuvrirFichier()
'Déclaration des variables
Dim xlsapp As Microsoft.Office.Interop.Excel.Application
Dim Xlsbook As Microsoft.Office.Interop.Excel.Workbook
'lancement d'excel et ouverture du fichier
xlsapp = New Microsoft.Office.Interop.Excel.Application
Xlsbook = xlsapp.Workbooks.Open("C:\fichier.xls")
xlsapp.Visible = True
Xlsheet.Range("A1").Value()
'déchargement d'excel
Xlsbook = Nothing
xlsapp = Nothing
End Sub
'Ouvrir le fichier après click sur Le menu.
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
OuvrirFichier()
End Sub
End Class |