有一个老项目,现在需要改进
用wincc6.2创建了一个按钮,编写按钮的动作时vbs动作,下面是执行代码。其中d:\shuju.xls是预先用excel创建好的。
dim fso,myfile
set fso = CreatObject("Scripting.FileSystemObject")
set myfile = fso.GetFile("d:\shuju.xls")
dim objExcelApp
set objExcelApp = CreatObject("Excel.Application")
objExcelApp.Visible = true
objExcelApp.Workbooks.Open myfile
dim aa_data
set aa_data = HMTRuntime.Tags("@ServerName")
aa_data.Read
objExcelApp.worksheets("sheet1").cells(1,2).VAlue = aa_data.Value
objExcelApp.worksheets("sheet2").cells(1,2).VAlue = aa_data.Value
objExcelApp.ActiveWorkbook.Save
objExcelApp.Workbook.close
set objExcelApp = nothing
可是运行画面,点击此按钮没有一点运行的标记。而且shuju.xls文件没有任何记录。
是我设置错误还是程序错误。还是不能这样运行。
求详细解答!
楼主最近还看过
Example 1: MS Excel
In this example, an output value from an input field is written in an Excel table.
‘VBS113
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 "<path>\ExcelExample.xls"
objExcelApp.Cells(4, 3).Value = ScreenItems("IOField1").OutputValue
objExcelApp.ActiveWorkbook.Save
objExcelApp.Workbooks.Close
objExcelApp.Quit
Set objExcelApp = Nothing
Dim objExcelApp
Set objExcelApp = CreateObject("Excel.Application")
objExcelApp.Visible = True
objExcelApp.Workbooks.Open "D:XQ\ExcelExample.xls"
objExcelApp.Cells(4, 3).Value = ScreenItems("IOField1").OutputValue
objExcelApp.ActiveWorkbook.Save
objExcelApp.Workbooks.Close
objExcelApp.Quit
Set objExcelApp = Nothing
为什么我便在在WINCC的一个按钮的VBS脚本里后 运行后画面上点那个按钮EXCEL的表画面跳了下就没了就闪了一下 谢谢哪位高手指点下