WINCC中的变量如何实时存在excel中?例如用WINCC Tag
WINCC中的变量如何实时存在excel中?例如用WINCC Tag simulator控制一个变量,变化的值按时间记录到excel中?中间需要组态之类的吗?程序之类有吗?具步骤是什么?一些按钮之类又是怎么弄?
答:按时间记录,你就要用全局脚本我这有vbs读写脚本的程序你参考一下:
Dim fso,myfile
Set fso=CreateObject("scripting.filesystemobject")
Set myfile=fso.GetFile("d:\\data_compare.xlsx")
Dim objexcelapp
Set objexcelapp=CreateObject("excel.application")
''objexcelapp.visible=true
objexcelapp.workbooks.open myfile
''以上是为了打开D盘excel文件
objexcelapp.worksheets("sheet1").cells(16,6).value=HMIRuntime.Tags("data_rec7.zq_m_aver1_1").Read
''以上是写数据到excel表格
Dim path,filename
filename=CStr(Year(Now))&"-"&CStr(Month(Now))&"-"&CStr(Day(Now))&"-"&CStr(Hour(Now))&"-"&CStr(Minute(Now))&"-"&CStr(Second(Now))
path="d:\datarec7\"&filename&"datacomp.xlsx"
objexcelapp.activeworkbook.SaveAs path
''以上是保存表格
objexcelapp.workbooks.close
objexcelapp.quit
Set objexcelapp=Nothing
''以上是关闭刚才打开的excel程序
答:按时间记录,你就要用全局脚本我这有vbs读写脚本的程序你参考一下:
Dim fso,myfile
Set fso=CreateObject("scripting.filesystemobject")
Set myfile=fso.GetFile("d:\\data_compare.xlsx")
Dim objexcelapp
Set objexcelapp=CreateObject("excel.application")
''objexcelapp.visible=true
objexcelapp.workbooks.open myfile
''以上是为了打开D盘excel文件
objexcelapp.worksheets("sheet1").cells(16,6).value=HMIRuntime.Tags("data_rec7.zq_m_aver1_1").Read
''以上是写数据到excel表格
Dim path,filename
filename=CStr(Year(Now))&"-"&CStr(Month(Now))&"-"&CStr(Day(Now))&"-"&CStr(Hour(Now))&"-"&CStr(Minute(Now))&"-"&CStr(Second(Now))
path="d:\datarec7\"&filename&"datacomp.xlsx"
objexcelapp.activeworkbook.SaveAs path
''以上是保存表格
objexcelapp.workbooks.close
objexcelapp.quit
Set objexcelapp=Nothing
''以上是关闭刚才打开的excel程序
新闻详情