自留地 :oops:
Dim xlApp
Dim xlWorkBook
Dim xlWorkSheet
Function CreateExcel(ExcelPath)
Set xlApp=createobject("Excel.Application")
sSourceFile=ExcelPath
Set fso=createobject("Scripting.filesystemobject")
'判断文件是否已存在
bFileExist=fso.FileExists(sSourceFile)
if bFileExist then
' 如果存在则打开
set xlWorkbook=xlApp.Workbooks.open(sSourceFile)
xlApp.visible=True
else
set xlWorkBook=xlApp.Workbooks.Add
set xlWorkSheet=xlWorkBook.Activesheet
xlApp.visible=True
xlWorkBook.saveas ExcelPath
End if
End Function
CreateExcel "c:\test.xls"