Option Strict On Option Explicit On Imports Microsoft.Office.Interop Public Class Form1 Private moXL As Excel.Application Private Sub Form1_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load moXL = New Excel.Application moXL.Visible = True moXL.Workbooks.Open("C:\a.xls") End Sub Private Sub Form1_FormClosing(ByVal sender As Object, ByVal e As System.Windows.Forms.FormClosingEventArgs) Handles Me.FormClosing moXL.Quit() End Sub End Class
Vous n’avez pas trouvé la réponse que vous recherchez ?
Posez votre questionOption Strict On Option Explicit On Imports Microsoft.Office.Interop Public Class Form1 Private moXL As Excel.Application Private Sub Form1_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load Dim oSh As Excel.Worksheet moXL = New Excel.Application moXL.Visible = True moXL.Workbooks.Open("C:\suivi CEN.xls") oSh = CType(moXL.ActiveSheet, Excel.Worksheet) oSh.Range("A1").Value = "Hello world !" oSh.Range("B1").Formula = "=12+31" End Sub Private Sub Form1_FormClosing(ByVal sender As Object, ByVal e As System.Windows.Forms.FormClosingEventArgs) Handles Me.FormClosing moXL.Quit() End Sub End Class