这个程序有个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