Eigenschappen. " Klik op " Referenties " en selecteer vervolgens " toevoegen . " Selecteer " COM " en klik op " Microsoft Excel 12.0 Object Library . " Klik op " OK . " Dubbelklik op " knop" op de " Tools" venster naar een nieuwe knop controle toe te voegen aan " Form1 . " Dubbelklik op " Button1 " om de " Form1.vb " module te openen .
Press 3 "Ctrl + A " en druk op " Delete " om alle code te verwijderen . Kopieer en plak de volgende code op uw " Form1.vb " module .
4
Invoer Microsoft.Office.Interop
Public Class Form1
Private Sub Button1_Click ( ByVal afzender als System.Object , ByVal e als System.EventArgs ) Handles Button1.Click
Dim ExcelApp
als Nieuwe Excel.Application
= True
Dim ExcelWbks ExcelApp.Visible
zoals Excel.Workbooks = ExcelApp.Workbooks
Dim ExcelWbk
zoals Excel.Workbook = ExcelWbks.Add
Dim ExcelShts
zoals Excel.Sheets = ExcelWbk.Worksheets
Dim ExcelSht
als Excel . . Werkblad = ExcelShts ( " Blad1 " )
ExcelSht.Range
( " A1 " ) Value = " Dit is een Microsoft Excel Office 2007 -werkblad "
ExcelSht.SaveAs
( " C : \\ my2007ExcelWorkbook.xlsx " )
End Sub End Class
Pers
5 " F5 "om uw programma uit te voeren en klik op " Button1 " naar een Microsoft Office Excel 2007-werkmap .