T
<p>I get info from an Excel file. The code I use is:
<pre>
'-----------------------------------------------------------------------
'--------- Communicate with Excel files -------------
'-----------------------------------------------------------------------
Dim excelfilename
Dim excel
Dim mainpath
Dim info
Dim step_info
excelfilename = HMIRuntime.ActiveProject.Path & "\Exceltomtest.xls"
Set excel = CreateObject("Excel.Application")
excel.Visible = True
excel.Workbooks.Open excelfilename
'step_info is an integer that gives us the line to read from the excel file
Set step_info = HMIRuntime.Tags("step_info")
info = excel.Cells(step_info.read, 2).Value
excel.Workbooks.Close
excel.Quit
Set excel = Nothing
'Show string on screen
ScreenItems("Step").Text = info
ScreenItems("Stepnr").Text = step_info.read
'------------------ End of communicate with Excel code --------------------------
</pre>
<p>My question is: I want to read out of this Excel file cyclic. So if my stepper changes then I don't have to reopen and close my Excel file again. Any ideas on this?
<pre>
'-----------------------------------------------------------------------
'--------- Communicate with Excel files -------------
'-----------------------------------------------------------------------
Dim excelfilename
Dim excel
Dim mainpath
Dim info
Dim step_info
excelfilename = HMIRuntime.ActiveProject.Path & "\Exceltomtest.xls"
Set excel = CreateObject("Excel.Application")
excel.Visible = True
excel.Workbooks.Open excelfilename
'step_info is an integer that gives us the line to read from the excel file
Set step_info = HMIRuntime.Tags("step_info")
info = excel.Cells(step_info.read, 2).Value
excel.Workbooks.Close
excel.Quit
Set excel = Nothing
'Show string on screen
ScreenItems("Step").Text = info
ScreenItems("Stepnr").Text = step_info.read
'------------------ End of communicate with Excel code --------------------------
</pre>
<p>My question is: I want to read out of this Excel file cyclic. So if my stepper changes then I don't have to reopen and close my Excel file again. Any ideas on this?
