各位高手,WINCC的实时EXECL报表我学了好几年,一是VB基础差二是没有在项目中实际操作,所以学学停停没有长进,现在我20天后的项目中需要报表并打印,应该是EXCEL比较合适。几年前网上下载的脚本做到全局脚本VBS的动作里,保存提示如图出错,是*错?脚本如下:
Option Explicit
Function action
strDateTime = FormatDateTime(Now(), 0)
strDate = Left(strDateTime, 10)
strHour = Right(Left(strDateTime, 13), 2) & " :00"
strminute = Right(Left(strDateTime, 16), 2)
iRow = Right(Left(strDateTime, 16), 2)
Set fs = CreateObject("Scripting.FileSystemObject")
IsCreate = fs.FileExists("D:\cyz\dayreport" & strDate & ".xls")
Set fs = Nothing
If IsCreate Then
strTemplateName = ("D:\cyz\dayreport" & strDate & ".xls")
Else
strTemplateName = "D:\cyz\moban\daymoban.xlt"
End If
Set m*cel = CreateObject("Excel.Application")
With m*cel
.Visible = False
.Workbooks.Open strTemplateName, , False
.ActiveWorkbook.ActiveSheet.Select
.DisplayAlerts = False
.Wait (Now() + 0.00002)
End With
m*cel.Worksheets(1).Cells(iRow + 2, 2).Value = strDate '日期
m*cel.Worksheets(1).Cells(iRow + 2, 3).Value = strHour
m*cel.Worksheets(1).Cells(iRow + 2, 9).Value = ("AI6")
m*cel.Worksheets(1).Cells(iRow + 2, 10).Value = ("AI7")
m*cel.Worksheets(1).Cells(iRow + 2, 11).Value = ("AI8")
m*cel.Worksheets(1).Cells(iRow + 2, 12).Value = ("AI9")
m*cel.ActiveWorkbook.SaveAs ("C:\cyz\dayreport" & strDate & ".xls")
m*cel.Quit
m*cel.DisplayAlerts = True
Set m*cel = Nothing
End Function
另外高手们能否帮忙解释下语句中关于EXCEL操作脚本的意思?
如果想EXCEL报表7:00或8:30开始第一班报表要改那一句?
敬请指教!不胜感激!
问题补充:
这个脚本是按日期出的EXCEL,不是按时间来的?
图片说明:
最佳答案
你可以参考一下我之前写过的,脚本注释的话都写上去了,一部分可以参考:
http://www.ad.siemens.com.cn/club/bbs/post.aspx?a_id=1683726&b_id=5&s_id=17&num=21#anch
提问者对于答案的评价:
谢谢
原创文章,作者:ximenziask,如若转载,请注明出处:https://www.zhaoplc.com/plc367833.html