Pensionskasse Kanton Solothurn
Niklaus Konrad-Strasse 4
4500 Solothurn
Montag – Freitag:
08.30 – 11.30 Uhr / 13.30 – 16.30 Uhr
Private Sub CreateExcelLateBinding() Dim xlApp As Object Dim xlWB As Object Dim xlWS As Object ' Create Excel without reference Set xlApp = CreateObject("Excel.Application") Set xlWB = xlApp.Workbooks.Add Set xlWS = xlWB.Worksheets(1)
' Format xlWS.Range("A1:B1").Font.Bold = True
xlApp.Visible = True
' Write data xlWS.Cells(1, 1).Value = "Hello from VB6" xlWS.Cells(1, 2).Value = "Using Excel 16.0"
' Clean up ' xlWB.SaveAs "C:\Temp\test.xlsx" ' xlWB.Close ' xlApp.Quit microsoft excel 16.0 object library download vb6
regsvr32 "C:\Program Files\Microsoft Office\root\Office16\EXCEL.EXE" Here's a complete feature that exports a VB6 DataGrid or FlexGrid to Excel 16.0:
' Clean up Set xlWS = Nothing Set xlWB = Nothing Set xlApp = Nothing Exit Sub ErrorHandler: MsgBox "Error: " & Err.Description, vbCritical If Not xlApp Is Nothing Then xlApp.Quit Set xlWS = Nothing Set xlWB = Nothing Set xlApp = Nothing End Sub If you don't want to set a reference, use late binding: Private Sub CreateExcelLateBinding() Dim xlApp As Object Dim
' Create Excel application Set xlApp = New Excel.Application Set xlWB = xlApp.Workbooks.Add Set xlWS = xlWB.Worksheets(1)