怎样用WINCC下全局脚本来实现报表。
问题补充:
有例子吗
最佳答案
Dim excelapp
Dim aa,bb,cc
Set excelapp = CreateObject("Excel.Application")
Set aa = HMIRuntime.tags("tag1")
excelapp.visible = False ''True
excelapp.workbooks.open "D:\excel.xls"
bb = Now
aa.Read
MsgBox CStr(bb)
excelapp.cells(1,1).value = "rrrrrr" ''111111
excelapp.cells(1,2).value = CStr(bb)
excelapp.cells(2,2).value = CStr(aa.value)
excelapp.cells(3,2).value = CInt(aa.value)
excelapp.cells(4,2).value = CSng(aa.value)
excelapp.cells(5,2).value = CDbl(aa.value)
excelapp.cells(6,2).value = CLng(aa.value)
excelapp.cells(3,3).value = ScreenItems("33").outputvalue
excelapp.cells(4,4).value = ScreenItems("35").outputvalue
cc = "D:\excel" + Mid(CStr(bb), 1, 4)+ Mid(CStr(bb), 6, 2)+ Mid(CStr(bb), 9, 2)+ Mid(CStr(bb), 12, 2)+ Mid(CStr(bb), 15, 2)+ Mid(CStr(bb), 18, 2) + ".xls"
MsgBox cc
excelapp.DisplayAlerts = False ''对打开的文件,直接保存时,避免弹出对话框窗口,而是直接覆盖
excelapp.activeworkbook.saveas cc ''根据当前日期时间,另存为新的文件
''excelapp.activeworkbook.save ’对打开的文件,直接保存
''excelapp.activeworkbook.saveAs "D:\excelcopy.xls" ’直接另存为新的文件
excelapp.workbooks.close
excelapp.quit
Set excelapp = Nothing
提问者对于答案的评价:
你的程序是在全局脚本下来实现的吧,我可以试试。谢谢
原创文章,作者:more0621,如若转载,请注明出处:https://www.zhaoplc.com/plc277915.html