Dim ExcelSheet As Object
Set ExcelSheet = CreateObject("Excel.Sheet")
ExcelSheet.Application.Visible = True
'在表格的第一個儲存格中寫些文字
ExcelSheet.Cells(1, 1).Value = "This is column A, row 1"
'將該表格儲存到 C:\test.doc 目錄
ExcelSheet.SaveAs "C:\ TEST.DOC"
Set ExcelSheet = CreateObject("Excel.Sheet")
ExcelSheet.Application.Visible = True
'在表格的第一個儲存格中寫些文字
ExcelSheet.Cells(1, 1).Value = "This is column A, row 1"
'將該表格儲存到 C:\test.doc 目錄
ExcelSheet.SaveAs "C:\ TEST.DOC"
文章標籤
全站熱搜

不同 Excel 版本的功能不要混用。 Excel 早就沒有 Sheet class 了。現在是用 WorkSheet。而且要取用 Excel 物件建議直接從 Application 物件開始。像你的程式必須要修改成: Dim objExcel As Object ' Excel.Application Dim objWorkbook As Object ' Excel.Workbook Dim objWorksheet As Object ' Excel.Worksheet Set objExcel = CreateObject("Excel.Application") objExcel.Visible = True Set objWorkbook = objExcel.Workbooks.Add Set objWorksheet = objWorkbook.Worksheets(1) '在表格的第一個儲存格中寫些文字 objWorksheet.Cells(1, 1).Value = "This is column A, row 1" '將該表格儲存到 C:\test.doc 目錄 objWorkbook.SaveAs "C:\TEST.XLS"
1.先設定專案引用項目:Microsoft EXCEL 9.0 Object Library 2.dim x as excel.application 3.set x = new excel.application 4.x.workbooks.add 5.x.cell(1,1).value = "HELLO" 就樣就可以了, 您也叫 Chris , 我們真是有綠