Hello,
i am new to PCAN Explorer and wanted a help regarding reading and writing function of VBScript Macros.
a signal is assigned to a vertical slider and i want to read value from a excel file (*.xlsx) and provide that value to that signal.
i got to know from help that it is possible to read and write Values using an .txt file. But i want to open an excel file (*.xlsx) using a macro and read a range of Values from a specific sheet (from a set of 8 sheets workbook), from a specific cell range (e.g. "A15 to A20"), and assign it to my signals one by one.
Similarly write a value obtained from another Signal to the same sheet but at different cell name (e.g. "E21").
is it possible to do so?
P.S. i am using a Button as a trigger to execute the Macro command
Thank you in advance.
Reading and writing to and from Excel
- PEAK-Support
- Sales & Support
- Posts: 1646
- Joined: Fri 10. Sep 2010, 19:34
Re: Reading and writing to and from Excel
This have nothing to do with PCAN-Explorer. Reading Data from a Excel Sheet in VBS is a Microsoft related problem.
here a simple code snip how to create a Excel connection:
This sample code create a new sheet and write to some cells - you also could open a existing sheet and read from cells.
here a simple code snip how to create a Excel connection:
Code: Select all
PrintToOutputWindow "create Excel connection"
Set objXL = CreateObject("Excel.Application")
objXL.Visible = True ' make it visible...also possible to bring to top
Set wbXL = objXL.Workbooks.Add()' ' New sheet
Set sXL = wbXL.Worksheets(1) ' goto Sheet1
' write Header
sXL.Cells(1,1) = "PEAK-System Technik PCAN-Explorer5 VBS Excel Demo (c)2013 PEAK Darmstadt"
sXL.Cells(3,1) = "No."
sXL.Cells(3,2) = "Voltage"
sXL.Cells(3,3) = "Current"
sXL.Cells(3,4) = "Power"
--------------------------------
PEAK-System Technik
Technical Support Team
support[at]peak-system.com
-------------------------------
PEAK-System Technik
Technical Support Team
support[at]peak-system.com
-------------------------------