在Excel中宏实现查询结果报表

用Excel中宏VB脚本实现显示查询wincc数据库中的数据,如查询2010-5-5一天几个属性0~23小时的数据

问题补充:
查询时间控件用日历控件 DTPicker(可以少做很多判断和验证代码—个人认为)

最佳答案

例子:                     
Dim fname,y,m,d,NO
Set y=HMIRuntime.Tags("year")
y.Read
y=CStr(y.Value)
Set m=HMIRuntime.Tags("month")
m.Read
m=CStr(m.Value)
Set d=HMIRuntime.Tags("day")
d.Read
d=CStr(d.Value)
‘Set NO=HMIRuntime.Tags("NO")
‘NO.Read
‘NO=CStr(NO.Value)
fname = "D:\Day_Report_"+ y + "-" + m + "-" + d +".xls"
Dim objExcelApp
Set objExcelApp = CreateObject("Excel.Application")
objExcelApp.Visible = True
‘ExcelExample.xls Is To create before executing this procedure.
‘Replace <path> With the real path of the file ExcelExample.xls.
objExcelApp.Workbooks.Open (fname)
‘objExcelApp.Cells(4, 3).Value = ScreenItems("IOField1").OutputValue
‘objExcelApp.ActiveWorkbook.PrintPreview
‘objExcelApp.ActiveWorkbook.PrintOut
‘objExcelApp.Workbooks.Close
‘objExcelApp.Quit
‘Set objExcelApp = Nothing

提问者对于答案的评价:
答案有些距离,不过还是谢谢你了!

原创文章,作者:more0621,如若转载,请注明出处:https://www.zhaoplc.com/plc269274.html

(0)
打赏 微信扫一扫 微信扫一扫 支付宝扫一扫 支付宝扫一扫
上一篇 2019年6月11日
下一篇 2019年6月11日

相关推荐