标题:我是搞自控的,wincc用到VBS脚本,打印一个表格,请帮我翻译一下,这个代码 ...
取消只看楼主
yuanzhihang
Rank: 1
等 级:新手上路
帖 子:12
专家分:0
注 册:2019-7-7
结帖率:0
已结贴  问题点数:20 回复次数:6 
我是搞自控的,wincc用到VBS脚本,打印一个表格,请帮我翻译一下,这个代码啥意思
Option Explicit
Function action

Dim oExcel,filename,c
Select Case Hour(Now())
Case 0  c=Hour(Now())+12
        filename="d:\报表\二网报表\"&Year(Date())&"年"&Month(Date())&"月"& Day(Date())&"日.xlsx"
        Set oExcel = CreateObject("Excel.Application")
            oExcel.displayalerts=False
            oExcel.Visible =False  
            oExcel.WorkBooks.Open("d:\报表\二网报表模板.xlsx" )
            oExcel.Workbooks(1).Activate
            oExcel.workbooks(1).SaveAs filename
            oExcel.quit
        Set oExcel=Nothing
Case 1  c=Hour(Now())+12
Case 2  c=Hour(Now())+12
Case 3  c=Hour(Now())+12
Case 4  c=Hour(Now())+12
Case 5  c=Hour(Now())+12
Case 6  c=Hour(Now())+12
Case 7  c=Hour(Now())+12
Case 8  c=Hour(Now())+12
Case 9  c=Hour(Now())+12
Case 10  c=Hour(Now())+12
Case 11  c=Hour(Now())+12
Case 12  c=Hour(Now())+12
Case 13  c=Hour(Now())+12
Case 14  c=Hour(Now())+12
Case 15  c=Hour(Now())+12
Case 16  c=Hour(Now())+12
Case 17  c=Hour(Now())+12
Case 18  c=Hour(Now())+12
Case 19  c=Hour(Now())+12
Case 20  c=Hour(Now())+12
Case 21  c=Hour(Now())+12
Case 22  c=Hour(Now())+12
Case 23  c=Hour(Now())+12
End Select
Set oExcel = CreateObject("Excel.Application")
oExcel.displayalerts=False
oExcel.Visible =False  
oExcel.WorkBooks.Open("d:\报表\二网报表\"&Year(Date())&"年"&Month(Date())&"月"& Day(Date())&"日.xlsx" )
oExcel.Workbooks(1).Activate
oExcel.Cells(c,2).Value = HMIRuntime.Tags("PT_101_3").Read
oExcel.Cells(c,3).Value = HMIRuntime.Tags("PT_101_4").Read
oExcel.Cells(c,4).Value = HMIRuntime.Tags("PT_201_4").Read
oExcel.Cells(c,5).Value = HMIRuntime.Tags("PT_301_4").Read
oExcel.Cells(c,6).Value = HMIRuntime.Tags("PT_101_6").Read
oExcel.Cells(c,7).Value = HMIRuntime.Tags("PT_107_6").Read
oExcel.Cells(c,8).Value = HMIRuntime.Tags("PT_101_7").Read
oExcel.Cells(c,9).Value = HMIRuntime.Tags("PT_101_8").Read
oExcel.Cells(c,10).Value = HMIRuntime.Tags("PT_102_3").Read
oExcel.Cells(c,11).Value = HMIRuntime.Tags("PT_102_4").Read
oExcel.Cells(c,12).Value = HMIRuntime.Tags("PT_202_4").Read
oExcel.Cells(c,13).Value = HMIRuntime.Tags("PT_102_6").Read
oExcel.Cells(c,14).Value = HMIRuntime.Tags("PT_108_6").Read
oExcel.Cells(c,15).Value = HMIRuntime.Tags("PT_102_7").Read
oExcel.Cells(c,16).Value = HMIRuntime.Tags("PT_102_8").Read
oExcel.Cells(c,17).Value = HMIRuntime.Tags("PT_302_4").Read
oExcel.Cells(c,18).Value = HMIRuntime.Tags("TE_101_3").Read
oExcel.Cells(c,19).Value = HMIRuntime.Tags("TE_101_4").Read
oExcel.Cells(c,20).Value = HMIRuntime.Tags("TE_201_4").Read
oExcel.Cells(c,21).Value = HMIRuntime.Tags("TE_301_4").Read
oExcel.Cells(c,22).Value = HMIRuntime.Tags("TE_101_6").Read
oExcel.Cells(c,23).Value = HMIRuntime.Tags("TE_107_6").Read
oExcel.Cells(c,24).Value = HMIRuntime.Tags("TE_101_7").Read
oExcel.Cells(c,25).Value = HMIRuntime.Tags("TE_101_8").Read
oExcel.Cells(c,26).Value = HMIRuntime.Tags("TE_106_3").Read
oExcel.Cells(c,27).Value = HMIRuntime.Tags("TE_107_3").Read
oExcel.Cells(c,28).Value = HMIRuntime.Tags("TE_102_4").Read
oExcel.Cells(c,29).Value = HMIRuntime.Tags("TE_202_4").Read
oExcel.Cells(c,30).Value = HMIRuntime.Tags("TE_302_4").Read
oExcel.Cells(c,31).Value = HMIRuntime.Tags("TE_102_6").Read
oExcel.Cells(c,32).Value = HMIRuntime.Tags("TE_108_6").Read
oExcel.Cells(c,33).Value = HMIRuntime.Tags("TE_106_7").Read
oExcel.Cells(c,34).Value = HMIRuntime.Tags("TE_107_7").Read
oExcel.Cells(c,35).Value = HMIRuntime.Tags("TE_102_8").Read
oExcel.Cells(c,36).Value = HMIRuntime.Tags("").Read
oExcel.Cells(c,37).Value = HMIRuntime.Tags("TE_001_8L").Read
oExcel.Cells(c,38).Value = HMIRuntime.Tags("").Read
oExcel.Cells(c,39).Value = HMIRuntime.Tags("TE_101_11").Read
oExcel.Cells(c,40).Value = HMIRuntime.Tags("TE_102_11").Read
oExcel.Cells(c,41).Value = HMIRuntime.Tags("TE_101_10").Read
oExcel.Cells(c,42).Value = HMIRuntime.Tags("TE_102_10").Read
oExcel.Cells(c,43).Value = HMIRuntime.Tags("TE_101_13").Read
oExcel.Cells(c,44).Value = HMIRuntime.Tags("TE_101_9").Read
oExcel.Cells(c,45).Value = HMIRuntime.Tags("TE_101_12").Read
oExcel.Cells(c,46).Value = HMIRuntime.Tags("FT_002_3").Read
oExcel.Cells(c,47).Value = HMIRuntime.Tags("FT_003_3").Read
oExcel.Cells(c,48).Value = HMIRuntime.Tags("FT_002_4").Read
oExcel.Cells(c,49).Value = HMIRuntime.Tags("FT_201_4").Read
oExcel.Cells(c,50).Value = HMIRuntime.Tags("FT_301_4").Read
oExcel.Cells(c,51).Value = HMIRuntime.Tags("FT_101_6").Read
oExcel.Cells(c,52).Value = HMIRuntime.Tags("FT_103_6").Read
oExcel.Cells(c,53).Value = HMIRuntime.Tags("FT_003_7").Read
oExcel.Cells(c,54).Value = HMIRuntime.Tags("FT_002_7").Read
oExcel.Cells(c,55).Value = HMIRuntime.Tags("FT_002_8").Read
oExcel.Cells(c,56).Value = HMIRuntime.Tags("TT-431/TT-431.PV_Out#Value").Read
oExcel.Cells(c,57).Value = HMIRuntime.Tags("TT-432/TT-432.PV_Out#Value").Read
oExcel.save
oExcel.quit
Set oExcel=Nothing


End Function
搜索更多相关主题的帖子: Case 报表 Date Value Read 
2019-07-07 21:12
yuanzhihang
Rank: 1
等 级:新手上路
帖 子:12
专家分:0
注 册:2019-7-7
得分:0 
2019-07-07 21:14
yuanzhihang
Rank: 1
等 级:新手上路
帖 子:12
专家分:0
注 册:2019-7-7
得分:0 
上面是表格,
2019-07-07 21:15
yuanzhihang
Rank: 1
等 级:新手上路
帖 子:12
专家分:0
注 册:2019-7-7
得分:0 
回复 5楼 风吹过b
非常感谢,真的是醍醐灌顶,昨天一直发愁,今天早早醒了,看了你的回复,清晰明了,非常感谢
2019-07-08 07:01
yuanzhihang
Rank: 1
等 级:新手上路
帖 子:12
专家分:0
注 册:2019-7-7
得分:0 
回复 4楼 wmf2014
我是搞PLC的,看了5楼的回复搞明白以后,才明白你的意思,真的像在织毛衣,太形象了
2019-07-08 07:03
yuanzhihang
Rank: 1
等 级:新手上路
帖 子:12
专家分:0
注 册:2019-7-7
得分:0 
回复 5楼 风吹过b
请问,如果以当前分钟为时间选择怎么修改,我是小白,请详细解释一下怎么修改,谢谢!
2019-07-08 07:19
yuanzhihang
Rank: 1
等 级:新手上路
帖 子:12
专家分:0
注 册:2019-7-7
得分:0 
回复 9楼 风吹过b
跪求回答,这个程序有个BUG,每次保存总是另存为,程序该怎么改?
2019-07-10 22:16



参与讨论请移步原网站贴子:https://bbs.bccn.net/thread-495738-1-1.html




关于我们 | 广告合作 | 编程中国 | 清除Cookies | TOP | 手机版

编程中国 版权所有,并保留所有权利。
Powered by Discuz, Processed in 0.085305 second(s), 9 queries.
Copyright©2004-2024, BCCN.NET, All Rights Reserved