Option Explicit
Function action
Dim objexcelapp,fso,myfile,dastr,fname,ts7,n,aa,m,h,mytime
dastr=FormatDateTime(Date)
fname="D:\myfile\"+dastr+".xls"
Set fso=CreateObject("s cripting.FileSystemObject")
Set objexcelapp=CreateObject("excel.application")
ts7=fso.FileExists(fname)
If ts7=False Then
Set MyFile=fso.GetFile("D:\myfile\shanhangwu.xls")
MyFile.Copy(fname)
n=4
End If
mytime=Now
m=Minute(mytime)
h=Hour(mytime)
objexcelapp.Workbooks.Open fname
If m/10=Int(m/10) Then
objexcelapp.Worksheets("sheet1").Cells(n,2).Value=HMIRuntime.Tags("F_101")
objexcelapp.Worksheets("sheet1").Cells(n,3).Value=HMIRuntime.Tags("F_102")
objexcelapp.Worksheets("sheet1").Cells(n,4).Value=HMIRuntime.Tags("F_103")
objexcelapp.Worksheets("sheet1").Cells(n,5).Value=HMIRuntime.Tags("F_104")
objexcelapp.Worksheets("sheet1").Cells(n,6).Value=HMIRuntime.Tags("F_105")
objexcelapp.Worksheets("sheet1").Cells(n,7).Value=HMIRuntime.Tags("L_501")
objexcelapp.Worksheets("sheet1").Cells(n,8).Value=HMIRuntime.Tags("L_502")
objexcelapp.Worksheets("sheet1").Cells(n,9).Value=HMIRuntime.Tags("L_503")
objexcelapp.Worksheets("sheet1").Cells(n,10).Value=HMIRuntime.Tags("P_101")
objexcelapp.Worksheets("sheet1").Cells(n,11).Value=HMIRuntime.Tags("P_102")
objexcelapp.Worksheets("sheet1").Cells(n,12).Value=HMIRuntime.Tags("P_103")
objexcelapp.Worksheets("sheet1").Cells(n,13).Value=HMIRuntime.Tags("P_104")
Else n=n+1
End If
objexcelapp.ActiveWorkbooks.Save
objexcelapp.Workbooks.Close
objexcelapp.Quit
Set objexcelapp=Nothing
Set MyFile=Nothing
Set fso=Nothing
End Function