求助:vfp操控excel问题
打开当前目录下的逐个xls文件,然后根据每个xls文件里面工作表表名调用不同程序进行处理nExcel=CreateObject('Excel.Application')
mbExcel = nexcel.Application.Workbooks.Open(SYS(5)+SYS(2003)"\汇总\汇总.xls")
oexcel = Createobject("excel.application")
xlsnumber = ADIR(xlsdata, '*.xls') && Create array
FOR nCount = 1 TO xlsnumber && Loop for number of databases
?xlsdata(nCount,1) && Display database names
xlsfilename=nowdir+'\'+xlsdata(nCount,1)
sjlyExcel = oexcel.Application.Workbooks.Open(xlsfilename)
With oExcel
lnSheetCount=.WorkBooks(1).Sheets.Count
Endwith
?xlsfilename+'中工作表的数目为:'+Alltrim(Str(lnSheetCount))
For Each oMyVar In oExcel.sheets
sheetname=oMyVar.Name
oExcel.Worksheets(sheetname).Activate
DO CASE
CASE 'a'$sheetname
do a
CASE 'b'$sheetname
do b
CASE 'c'$sheetname
do c
OTHERWISE
ENDCASE
Next oMyVar
oExcel.WORKBOOKS.Close &&关闭工作簿
ENDFOR
到了这关闭工作簿这句:oExcel.WORKBOOKS.Close,系统就死机了,为何?