Visual Basic Scripting Example - 2021.2 English

Xilinx Power Estimator User Guide (UG440)

Document ID
UG440
Release Date
2021-10-22
Version
2021.2 English

This simple example opens XPE, then export results into a text power report using the Visual Basic scripting language.

Dim XPE As Workbook
XPEfilename = "C:\\Power\\7_Series_XPE_13_1.xls"

On Error Resume Next
Set XPE = Workbooks(XPEfilename)
  ' Opening XPE
  On Error GoTo 0
  If (XPE Is Nothing) Then
     Set XPE = Application.Workbooks.Open(XPEfilename, UpdateLinks:=vbFalse,
ReadOnly:=vbTrue)
     If XPE Is Nothing Then ' Open failed
        MsgBox ("XPE Open Failed: " & XPEfilename & "Err=" & Err)
        Exit Function
     End If
  End If
' Set Vccint voltage
XPE.Sheets("Summary").Range("VCCINT").Value = myVccint
TotalPower = XPE.Sheets("Summary").Range("TOTAL_POWER").Value
' Export XPE results into a text power report
XPESub = "'" & XPE.Name & "'!" & "ThisWorkBook.GeneratePowerReportFile"
Application.Run(XPESub, FileName)