Option Explicit
Function action
Dim DataLogSel
DataLogSel=HMIRuntime.Tags("DataLogSel").read
If DataLogSel=1 Then
Dim fname,dstr
dstr=FormatDateTime(Date)
fname="E:\"+dstr+".xls"
Dim ObjExcelApp,fso,MyFile
Set objExcelApp = CreateObject("Excel.Application")
Set fso = CreateObject("s cripting.FileSystemObject")
If fso.FileExists(fname) Then
objExcelApp.Workbooks.Open fname
Else
Set MyFile=fso.GetFile("E:\book.xls")
MyFile.Copy(fname)
objExcelApp.Workbooks.Open fname
End If
objExcelApp.Visible = False
Dim i
i=2
Do While objExcelApp.worksheets ("sheet1").Cells(i, 1).VAlue<>""
i=i+1
Loop
objExcelApp.worksheets ("sheet1").Cells(i, 2).VAlue = HMIRuntime.Tags("泵出口流量").read
objExcelApp.worksheets ("sheet1").Cells(i, 3).VAlue = HMIRuntime.Tags("过滤器后流量").read
objExcelApp.worksheets ("sheet1").Cells(i, 4).VAlue = HMIRuntime.Tags("加药流量").read
objExcelApp.worksheets ("sheet1").CelLs(i, 5).VAlue = HMIRuntime.Tags("过滤器后压力").read
objExcelApp.worksheets ("sheet1").Cells(i, 6).VAlue = HMIRuntime.Tags("灭活器后压力").read
objExcelApp.worksheets ("Sheet1").Cells(i, 7).VAlue = HMIRuntime.Tags("旋分器后压力").read
objExcelApp.worksheEts ("sheet1").Cells(i, 8).VAlue = HMIRuntime.Tags("旋分器跨接阀前压力").read
objExcelApP.worksheets ("sheet1").Cells(i, 9).VAlue = HMIRuntime.Tags("旋分器入口压力").read
objEXcelApp.worksheets ("sheet1").Cells(i, 10).VAlue = HMIRuntime.Tags("主泵出口压力").reaD
objExcelApp.worksheets ("sheet1").Cells(i, 11).Value = HMIRuntime.Tags("过滤罐1压差表").Read
objExcelApp.worksheets ("sheet1").Cells(i, 1).VAlue =Now
objExcelApp.ActiveWorkbook.save
objExcelAPp.Workbooks.ClosE
ojEXcelapp.quiT
Set ObjEXceLapp = Nothing
End If