-> Hier kostenlos registrieren
Hallo Leute,
ich habe es in der letzen Zeit mit Hilfe des Forums schon geschafft, Werte aus einer Excel-Liste auf WinCC-Variablen zu schreiben. Klappt super.
Jetzt benötige ich blöderweise die umgekehrte Richtung, also WinCC-Variablenwerte in Excel ablegen.
Kann ich (wenn ja wie) mein Script hierzu entsprechend umbiegen?
Gruß
Move
Script: (Werte Excel->WinCC):
Option Explicit
Function action
Dim excel, wbActive, wsActive
'Create an Excel-Application object
Set excel = CreateObject("Excel.Application")
excel.Visible = 0
Set wbActive = excel.Workbooks.Open("D:\Projekt\KIS\Prognosen\KIS Wetterprognose WinCC.xls")
Set wsActive = wbActive.Worksheets("Tabelle1")
'----------------- WinCC Variable schreiben --------------------
'wsActive.cells(3,2) = Zeile 3, Spalte 2
'Temperaturwerte -> S7 schreiben
Dim objTag
Set objTag = HMIRuntime.Tags("Temp_00_T0_B2") ' Temperatur 0:00 Uhr
objTag.Value = wsActive.cells(2,2).Value
objTag.Write
wbActive.Close True 'Exceldatei schliessen
excel.Quit 'Excel schliessen
Set wsActive = Nothing 'Speicher freigeben
Set wbActive = Nothing
Set excel = Nothing
End Function
ich habe es in der letzen Zeit mit Hilfe des Forums schon geschafft, Werte aus einer Excel-Liste auf WinCC-Variablen zu schreiben. Klappt super.
Jetzt benötige ich blöderweise die umgekehrte Richtung, also WinCC-Variablenwerte in Excel ablegen.
Kann ich (wenn ja wie) mein Script hierzu entsprechend umbiegen?
Gruß
Move
Script: (Werte Excel->WinCC):
Option Explicit
Function action
Dim excel, wbActive, wsActive
'Create an Excel-Application object
Set excel = CreateObject("Excel.Application")
excel.Visible = 0
Set wbActive = excel.Workbooks.Open("D:\Projekt\KIS\Prognosen\KIS Wetterprognose WinCC.xls")
Set wsActive = wbActive.Worksheets("Tabelle1")
'----------------- WinCC Variable schreiben --------------------
'wsActive.cells(3,2) = Zeile 3, Spalte 2
'Temperaturwerte -> S7 schreiben
Dim objTag
Set objTag = HMIRuntime.Tags("Temp_00_T0_B2") ' Temperatur 0:00 Uhr
objTag.Value = wsActive.cells(2,2).Value
objTag.Write
wbActive.Close True 'Exceldatei schliessen
excel.Quit 'Excel schliessen
Set wsActive = Nothing 'Speicher freigeben
Set wbActive = Nothing
Set excel = Nothing
End Function