发布于 2012-08-21 18:53:59
4楼
奇侠老师,我试着比照您的附件制作了一段VBS,但居然连EXCEL表都没有打开,反复试验没弄明白问题原因,请指教。
Sub OnClick(ByVal Item)
Dim ObjExcelApp
Set objExcelApp = CreateObject("Excel.Application")
objExcelApp.Visible = True
objExcelApp.Workbooks.Open "d:\data.xls"
objExcelApp.Worksheets("sheet1").Activate
Dim m ,i
Set m= objExcelApp.worksheets("sheet1").Cells(1,10).Value
Do While m>0
objExcelApp.worksheets("sheet1").Cells(i,1).VAlue=objExcelApp.worksheets ("sheet1").Cells(i+1, 1).VAlue
objExcelApp.worksheets("sheet1").Cells(i,2).VAlue=objExcelApp.worksheets ("sheet1").Cells(i+1, 2).VAlue
i=i+1
Loop
objExcelApp.worksheets ("sheet1").Cells(i, 1).VAlue =HMIRuntime.Tags("yy").read
objExcelApp.worksheets ("sheet1").Cells(i, 2).VAlue =HMIRuntime.Tags("xx").read
objExcelApp.ActiveWorkbook.Save
objExcelApp.Workbooks.Close
objExcelApp.Quit
End Sub