Option Explicit
Function action
Dim objExcelAPP
Dim reportfile
Dim reportfile1
Dim reporttime
Dim index
Dim j
Dim i
index=Hour(Now)
index=CInt(index)
reportfile=CStr(Date)
reporttime=Hour(Now)
reporttime=CStr(reporttime)
reportfile=reportfile
reportfile1=reportfile
reportfile="D:\report\" & reportfile & ".xls"
Dim TEMP_1
Set TEMP_1 = HMIRuntime.Tags("TEMP_1")
Dim TEMP_2
Set TEMP_2 = HMIRuntime.Tags("TEMP_2")
Dim TEMP_3
Set TEMP_3 = HMIRuntime.Tags("TEMP_3")
Dim TEMP_4
Set TEMP_4 = HMIRuntime.Tags("TEMP_4")
Dim TEMP_5
Set TEMP_5 = HMIRuntime.Tags("TEMP_5")
Dim TEMP_6
Set TEMP_6 = HMIRuntime.Tags("TEMP_6")
Dim TEMP_7
Set TEMP_7 = HMIRuntime.Tags("TEMP_7")
Dim TEMP_8
Set TEMP_8 = HMIRuntime.Tags("TEMP_8")
Dim TEMP_9
Set TEMP_9 = HMIRuntime.Tags("TEMP_9")
Dim flow_1
Set flow_1 = HMIRuntime.Tags("flow_1")
Dim flow_2
Set flow_2 = HMIRuntime.Tags("flow_2")
Dim reportname
Set reportname = HMIRuntime.Tags("reportname")
TEMP_1.Read
TEMP_2.Read
TEMP_3.Read
TEMP_4.Read
TEMP_5.Read
TEMP_6.Read
TEMP_7.Read
TEMP_8.Read
TEMP_9.Read
flow_1.Read
flow_2.Read
Set objExcelAPP=CreateObject("Excel.Application")
objExcelAPP.Visible=False
objExcelAPP.Workbooks.Open "D:\report\book1.xls"
With objExcelAPP
If index=0 Then
For i=5 To 28
For j= 2 To 12
.cells(i,j).value=Null
Next
Next
.cells(2,2).value=Date
End If
j=0
j=index+5
.cells(j,2).value=TEMP_1.Value
.cells(j,3).value=TEMP_2.Value
.cells(j,4).value=TEMP_3.Value
.cells(j,5).value=TEMP_4.Value
.cells(j,6).value=TEMP_5.Value
.cells(j,7).value=TEMP_6.Value
.cells(j,8).value=TEMP_7.Value
.cells(j,9).value=TEMP_8.Value
.cells(j,10).value=TEMP_9.Value
.cells(j,11).value=flow_1.Value
.cells(j,12).value=flow_2.Value
If index=23 Then
''.cells(30,3).value=FY1901ACC2.Value
''.cells(30,5).value=FY1901ACC1.Value
''.cells(30,8).value=FT1908ACC2.Value
''.cells(30,10).value=FT1908ACC1.Value
.ActiveWorkbook.SaveAs reportfile
reportname.Write reportfile1
Else
.ActiveWorkbook.Save
End If
.ActiveWorkbook.Close
.Quit
End With
Set objExcelAPP=Nothing
End Function
此段程序是向EXCEL表格定时写变量值,我怎样才能每1分钟自动记录一次啊 并且 在我的EXCEL表格中自动生成系统的每次计时啊 帮帮忙修改下 前辈们
最佳答案
你可以让你的脚本每分钟执行一次。
提问者对于答案的评价:
那我要求的在EXCEL表格里显示的系统时间怎么才能让它自动显示 而无需人工添加呢 请具体的帮忙修改下
原创文章,作者:more0621,如若转载,请注明出处:https://www.zhaoplc.com/plc277877.html