09.03.2013 Views

Simulator 16 User Guide - PowerWorld

Simulator 16 User Guide - PowerWorld

Simulator 16 User Guide - PowerWorld

SHOW MORE
SHOW LESS

You also want an ePaper? Increase the reach of your titles

YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.

GetParametersMultipleElement Function: Sample Code Microsoft® Visual Basic for Excel<br />

Private Sub btnGetParametersMultiple_Click()<br />

Dim objtype, filter As String<br />

Dim xlWB As Excel.Workbook<br />

Set xlApp = Excel.Application<br />

' Checks connection and open case<br />

' SimAuto and caseopen are global variables<br />

If Not SimAuto Is Nothing And caseopen Then<br />

objtype = "bus"<br />

filter = ""<br />

Dim fieldArray As Variant<br />

fieldArray = Array("pwBusNum", "pwBusName", "pwBusKVVolt", _<br />

"pwBusPUVolt", "pwBusAngle")<br />

output = SimAuto.GetParametersMultipleElement(objtype, fieldArray, filter)<br />

If output(0) "" Then<br />

DisplayErrorMessage output(0)<br />

Else<br />

DisplayMessage "Succesful GetParametersSingleElement"<br />

' Prepares additional worksheet<br />

Set xlWB = xlApp.Workbooks.Add<br />

' Copies list of devices in worksheet<br />

With xlWB<br />

Sheets("sheet2").Activate<br />

Sheets("sheet2").Name = "GetParametersSingleElement"<br />

With Sheets("GetParametersSingleElement")<br />

Dim i, j As Integer<br />

Range(Cells(1, 5), Cells(200, 7)).Clear<br />

Cells(1, 1) = "List of Devices for " + objtype + ":"<br />

' Setup fields as subheader<br />

For i = LBound(fieldArray) To UBound(fieldArray)<br />

Cells(2, i + 1) = fieldArray(i)<br />

Next i<br />

' Determine number of fields retrieved<br />

Dim lowfld, highfld As Integer<br />

lowfld = LBound(output(1), 1)<br />

highfld = UBound(output(1), 1)<br />

' Determine number of objects retrieved<br />

©2011 <strong>PowerWorld</strong> Corporation<br />

1419

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!