Subject: Scripting Example Posted: 2/21/2018 Viewed: 8724 times
Dear WEAP users,
I would like to share with you a script that automates WEAP to run number of times (each with a different value of hydropower demand) and then write the results out in one excel sheet.Hope you find it useful
set xla=CreateObject("Excel.Application")
xla.Visible=true
xla.ScreenUpdating=false
set xlw=xla.workbooks.Add
set xls=xlw.sheets.Add
set WEAP=CreateObject("WEAP.WEAPApplication")
WEAP.Verbose=1
WEAP.ActiveArea="Tutorial"
WEAP.Versions("HDresult").Revert
WEAP.ActiveScenario="Reference"
e=0
m=2
xls.Cells(1,1)="Year"
For i=0 To 10
z=2
e=e+0.10
WEAP.Branch("Supply and Resources\River\Main River\Reservoirs\Big City Reservior").Variables("Energy Demand").Expression=e
Call WEAP.LoadFavorite("Hydropower Generation")
For j=WEAP.BaseYear To WEAP.EndYear
xls.Cells(z,1)=j
xls.Cells(1,m)=e
xls.Cells(z,m)=WEAP.ResultValue("\Supply and Resources\River\Main River\Reservoirs\Big City Reservior:Hydropower Generation", j, 1, "Reference", j, 12)
z=z+1
Next
m=m+1
Next