' Format xlWS.Range("A1:B1").Font.Bold = True
' 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: 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: ' Format xlWS
' Example: Export from MSFlexGrid (assuming you have one named MSFlexGrid1) With MSFlexGrid1 For i = 0 To .Rows - 1 For j = 0 To .Cols - 1 xlWS.Cells(i + 1, j + 1).Value = .TextMatrix(i, j) Next j Next i End With j + 1).Value = .TextMatrix(i
' Make Excel visible (optional) xlApp.Visible = True