大家好,想问两个问题啊,先谢谢啦
1.wincc写入excel表格数据后,表格晃了一下,就关掉了,我想写完之后,显示表格(现在objexcelapp.visible=true),疑惑啊
2.objexcelapp.cells(4,3).value=screenitem("输入输出域18").outputvalue,如果想写入不同画面的输入输出域,该怎么写??
专家建议
1. 请参考,希望能够有所帮助:
'Example 1: MS Excel
'In this example, an output value from an input field is written in an Excel table.
'VBS113
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 'getcurrent_datetime()
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
2. WinCC中只能对当前打开画面中的对象进行控制,设置未打开画面中的对象属性会有错误提示。
提问者对于答案的评价:
原创文章,作者:more0621,如若转载,请注明出处:https://www.zhaoplc.com/plc310955.html