| 网站首页 | 业界新闻 | 小组 | 威客 | 人才 | 下载频道 | 博客 | 代码贴 | 在线编程 | 编程论坛
欢迎加入我们,一同切磋技术
用户名:   
 
密 码:  
共有 1804 人关注过本帖
标题:这个程序有个BUG,就是每次保存的时候总是提示另存为,程序该怎么修改?
取消只看楼主 加入收藏
yuanzhihang
Rank: 1
等 级:新手上路
帖 子:12
专家分:0
注 册:2019-7-7
结帖率:0
收藏
已结贴  问题点数:20 回复次数:4 
这个程序有个BUG,就是每次保存的时候总是提示另存为,程序该怎么修改?
我是搞自控的,wincc用到VBS脚本,打印一个表格,但是这个程序有个BUG,就是每次保存的时候总是提示另存为,程序该怎么修改?
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-10 22:19
yuanzhihang
Rank: 1
等 级:新手上路
帖 子:12
专家分:0
注 册:2019-7-7
收藏
得分:0 
回复 2楼 风吹过b
搞了一天了,复制来复制去,实在搞不定,我以前从来没搞过
2019-07-10 23:13
yuanzhihang
Rank: 1
等 级:新手上路
帖 子:12
专家分:0
注 册:2019-7-7
收藏
得分:0 
回复 2楼 风吹过b
进程里面确实有很多进程,删掉以后还是会出现呀
2019-07-10 23:18
yuanzhihang
Rank: 1
等 级:新手上路
帖 子:12
专家分:0
注 册:2019-7-7
收藏
得分:0 
回复 4楼 yuanzhihang
为什么我的Excel每次保存都会产生一个进程,如果把进程结束,就不会另存为了
2019-07-10 23:39
yuanzhihang
Rank: 1
等 级:新手上路
帖 子:12
专家分:0
注 册:2019-7-7
收藏
得分:0 
回复 2楼 风吹过b
怎样加一段程序,杀死excel进程啊
2019-07-11 09:52
快速回复:这个程序有个BUG,就是每次保存的时候总是提示另存为,程序该怎么修改 ...
数据加载中...
 
   



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

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