发布于 2006-07-05 13:46:02
0楼
Option Explicit
Function action
Dim fso,myfilep,daystr,dstr,fname
Set fso = CreateObject("s cripting.FileSystemObject")
dstr = FormatDateTime(Date)
HMIRuntime.Tags("i").write fso.GetAbsolutePathName("")
fname=HMIRuntime.ActiveProject.Path++dstr+.xls
Dim ObjExcelApp
Set objExcelApp = CreateObject("Excel.Application")
objExCelApp.Visible = True
objExcelApp.Workbooks.Open fname
Dim i
i=1
Do While objExcelApp.worksheets ("sheet1").Cells(i, 1).VAlue<>""
i=i+1
Loop
objExcelApp.worksheets ("sheet1").Cells(i, 2).VAlue = HMIRuntime.Tags("I-COD").read
objExcelApp.worksheets ("sheet1").Cells(i, 3).VAlue = HMIRuntime.Tags("I-SS").read
objExcelApp.worksheets ("sheet1").Cells(i, 4).VAlue = HMIRuntime.Tags("I-PH").read
objExcelApp.worksheets ("sheet1").Cells(i, 5).VAlue = HMIRuntime.Tags("I-F").read
objExcelApp.worksheets ("sheet1").Cells(i, 6).VAlue = HMIRuntime.Tags("I-FI").read
objExcelApp.worksheets ("sheet1").Cells(i, 7).VAlue = HMIRuntime.Tags("O-COD").read
objExcelApp.worksheets ("sheet1").Cells(i, 8).VAlue = HMIRuntime.Tags("O-SS").read
objExcelApp.worksheets ("sheet1").Cells(i, 9).VAlue = HMIRuntime.Tags("O-NH4N").read
objExcelApp.worksheets ("sheet1").Cells(i, 10).VAlue = HMIRuntime.Tags("0-P").read
objExcelApp.worksheets ("sheet1").Cells(i, 11).VAlue = HMIRuntime.Tags("O-F").read
objExcelApp.worksheets ("sheet1").Cells(i, 12).VAlue = HMIRuntime.Tags("O-FI").read
objExcelApp.worksheets ("sheet1").Cells(i, 1).VAlue =Now
objExcelApp.ActiveWorkbook.Save
objExcelApp.Workbooks.ClosE
objExcelApp.QuiT
Set ObjEXceLapp = Nothing
End Function
这一段怎么运行不了啊 显示fname=HMIRuntime.ActiveProject.Path++dstr+.xls这段错误