<< Click to Display Table of Contents >>
Main File |
The main file must be an Excel workbook saved in XLSM (Macro-Enabled Workbook) format. A workbook usually contains the next spreadsheets.
•INFOS spreadsheet
•Device_List spreadsheet
•A spreadsheet for each Substation, such as SUB01 and SUB02
•A spreadsheet for each model of remote network device, such as Cooper_F6 and NULEC_ADVC2
Other tabs can be created for other purposes during the project's development, such as defining alarms, as long as the respective load library be developed in Elipse Power to consume such data.
The SaveAllAsCsv macro must be present on Excel's View - Macros - View Macros menu. When clicking Edit or Create, the Microsoft Visual Basic for Applications window is opened. The code for this macro is presented next.
Sub SaveAllAsCsv()
Dim ws As Excel.Worksheet
Dim fileDir As String
Dim currentWorkbook As String
Dim currentFormat As Long
currentWorkbook = ThisWorkbook.FullName
currentFormat = ThisWorkbook.FileFormat
fileDir = ActiveWorkbook.Path & "\"
For Each ws In ThisWorkbook.Worksheets
Sheets(ws.Name).Copy
ActiveWorkbook.SaveAs Filename:=fileDir & ws.Name & ".csv", FileFormat:=xlCSV, Local:=True
ActiveWorkbook.Close savechanges:=False
ThisWorkbook.Activate
Next
Application.DisplayAlerts = False
ThisWorkbook.SaveAs Filename:=currentWorkbook, FileFormat:=currentFormat
Application.DisplayAlerts = True
End Sub
Save the program and close the window. Go to Excel and execute this macro. Each spreadsheet from the workbook is exported to the CSV format on the same folder of the main file.
From now on, Elipse Power can read the content of those spreadsheets using a FileSystemObject object, available for use with the VBScript language. The same process is not so trivial when trying to read the content of those files in XLS or XLSM format directly from an Excel workbook. The structure of each file is presented on the next topics.