Dim Excel As Excel.Application ' This is the excel program
Dim ExcelWBk As Excel.Workbook ' This is the work book
Dim ExcelWS As Excel.Worksheet ' This is the sheet
Private Sub StartExcel()
On Error GoTo err:
Set Excel = GetObject(, "Excel.Application") ' Create Excel Object.
'Excel.Visible = True ' Show Excel
Exit Sub
err:
Set Excel = CreateObject("Excel.Application") 'Create Excel Object.
End Sub
'启动excel程序
Call StartExcel
Set ExcelWBk = Nothing
Set ExcelWS = Nothing
Set ExcelWBk = Excel.Workbooks.Add 'Add this Workbook to Excel.
Set ExcelWS = ExcelWBk.Worksheets("sheet1") ' Add this sheet to this Workbook
'ExcelWBk.Worksheets("sheet1").name = "Data"
Excel.Visible =true