发表于:2007-08-09 12:33:00
楼主
看了论坛中其他WinCC与Excel的互连的文章,我也把另一种途径与大家分享,虽然复杂一点,但是运行还算稳定,读写方便。
Dim objExcelApp
Set objExcelApp = CreateObject("Excel.Application")
objExcelApp.Visible = True
'
Dim NO
Set NO = HMIRuntime.Tags("NO")
Dim TrackNO
Set TrackNO = HMIRuntime.Tags("TrackNO")
Dim Company
Set Company = HMIRuntime.Tags("Company")
Dim SheetNO
Set SheetNO = HMIRuntime.Tags("SheetNO")
Dim Product
Set Product = HMIRuntime.Tags("Product")
Dim SetPoint
Set SetPoint = HMIRuntime.Tags("SetPoint")
objExcelApp.Workbooks.Open"D:\UCC\data\Book1.xls"
NO.Value = objExcelApp.Cells(2,1).Value
TrackNO.Value = objExcelApp.Cells(2,2).Value
Company.Value = objExcelApp.Cells(2,3).Value
SheetNO.Value = objExcelApp.Cells(2,4).Value
Product.Value = objExcelApp.Cells(2,5).Value
SetPoint.Value = objExcelApp.Cells(2,6).Value
objExcelApp.ActiveWorkbook.Save
objExcelApp.Workbooks.Close
objExcelApp.Quit
Set objExcelApp = Nothing
NO.Write
TrackNO.Write
Company.Write
SheetNO.Write
Product.Write
SetPoint.Write