Function SaveWorkBook(objExcelApp,workbookIdentifier,path)
Dim workbook
On error resume next
Set workbook=objExcelApp.Workbooks(workbookIdentifier)
On error goto 0
If not workbook is nothing Then
If path="" or path=workbook.FullName or path=workbook.Name Then
workbook.Save
Else
Set objFso=createobject("Scripting.FileSystemObject")
'if the path has no file extension than and the 'xlsx' extension
If instr(path,".")=0 Then
path=path & ".xlsx"
End If
On error resume next
objFso.DeleteFile path
Set objFso=nothing
Err=0
On error goto 0
workbook.SaveAs path
End If
SaveWorkBook="OK"
else
SaveWorkBook="Bad Workbook Identifier"
End If
End Function
谢谢您的分析,这样条理更清楚了。作者: auto_tester 时间: 2014-4-21 14:33
学习了!作者: auto_tester 时间: 2014-4-22 11:13
For i = 1 To 3 Step 1
For j = 1 To 3 Step 1
Set excel = createobject("Excel.Application")
excel.Workbooks.Open "D:\Test.xlsx"
Set osheet = excel.Sheets.Item(1)
d =osheet.cells(i,j)
print d
next
next