Wincc - Read out of an Excel file

T

Thread Starter

Tom

<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?
 
> 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</pre>
I am trying to do something similar, Have you been able to implement this? If so then please help me. I am using WinCC 7.0. I have a CSV file of sensor's data that is being updated continuously by the data sent by sensor wireless, I want to show the latest sensor's reading in WinCC. Is it possible?

Thanks
khyzer<pre>
> 'Show string on screen
> ScreenItems("Step").Text = info
> ScreenItems("Stepnr").Text =
> step_info.read
>
> '------------------ End of communicate with Excel code
> --------------------------</pre>
> 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?
 
Top