可以,你試一下:
Dim exlApp As Excel.Application
Dim exlBook As Excel.Workbook
Set exlApp = New Excel.Application
exlApp.Visible = True "顯示Excel視窗
Set exlBook = exlApp.Workbooks.Open(App.Path + "\test.xls") "Excel檔案路徑及檔名
"向Excel表中寫入資料,Sheets(1)為第1個工作表,Cells(行號,列號)是單元格
exlApp.Sheets(1).Cells(1, 1) = "11"
exlApp.Sheets(1).Cells(1, 2) = "12"
exlApp.Sheets(1).Cells(2, 1) = "21"
exlApp.DisplayAlerts = False "不顯示警告資訊
exlBook.Close True "先儲存修改再關閉工作簿
exlApp.Quit "關閉Excel
可以,你試一下:
Dim exlApp As Excel.Application
Dim exlBook As Excel.Workbook
Set exlApp = New Excel.Application
exlApp.Visible = True "顯示Excel視窗
Set exlBook = exlApp.Workbooks.Open(App.Path + "\test.xls") "Excel檔案路徑及檔名
"向Excel表中寫入資料,Sheets(1)為第1個工作表,Cells(行號,列號)是單元格
exlApp.Sheets(1).Cells(1, 1) = "11"
exlApp.Sheets(1).Cells(1, 2) = "12"
exlApp.Sheets(1).Cells(2, 1) = "21"
exlApp.DisplayAlerts = False "不顯示警告資訊
exlBook.Close True "先儲存修改再關閉工作簿
exlApp.Quit "關閉Excel