菜鸟请教:vb操作excel的问题
Option Explicit
dim beginrow
DIM EXCEL,workBook,dirSheet
set EXCEL = CREATEOBJECT("Excel.Application")
excel.visible=true
set workBook=EXCEL.workbooks.add(-4167)'新建工作簿
workBook.sheets(1).name ="表结构"
'set dirSheet = workBook.sheets("表结构")
workBook.Sheets.Add After:=Worksheets(Worksheets.count)
'worksheets("表1").Move after:=worksheets("表结构")
以上代码,我是想将新建的工作表放到最后,但运行代码始终报错,
还望高手指点啊,多谢!!
[解决办法]
vbs 中应该是不支持命名参数的语法的。
workBook.Sheets.Add After:=Worksheets(Worksheets.count)
'要更改为
workBook.Sheets.Add , Worksheets(Worksheets.count)
workBook.Sheets.Add After:=Worksheets(Worksheets.count)
'改为
Workbook.Sheets.Add Null, Workbook.Sheets(Workbook.Sheets.Count), Null, Null
'或者
workBook.Sheets.Add , Workbook.Sheets(Workbook.Sheets.count)