Welcome to WEAP's Website WEAP
WEAP is an initiative of the Stockholm Environment Institute.


About WEAP

Home
Why WEAP?
Features
What's New?
Sample Screens
Demonstration
Publications
History and Credits

Using WEAP
Download
Licensing
User Guide
Tutorial
Videos

User Forum
Discussions
Members List
Edit Profile

Additional Support
Training
University Courses
Collaboration

About Us
SEI-US Water Resources Program
Please Contact Us


Environmental News
LEAP
Interested in Energy?
Read about LEAP: SEI's software for energy planning.
   

User Forum

All Topics | Topic "Scripting Example"
Log in to post new messages or reply to existing messages.
 
Author Message
Mr. Mohammed Yassin

Subject: Scripting Example   
Posted: 2/21/2018 Viewed: 254 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
Topic "Scripting Example"