Subject: Importing New Branches into WEAP from Excel Posted: 4/28/2016 Viewed: 13378 times
I am developing a water management model of certain African countries in WEAP. I had to make a 'Key Assumption' to represent 1000 small districts and their population. I was wondering if I could have it in Excel and directly import them into WEAP. But i did some digging on the user Manuals and it had the following words
"WEAP can only import data that corresponds to an existing branch/variable/scenario"
So i believe that I need to create these 1000 branches in WEAP and then I can use the import/export function to deal with the EXPRESSIONS.
Can someone guide me if my understanding is right and if wrong, how do i take numerous amount of branches into WEAP without clicking and adding them one by one.
Mr. Jack Sieber
Subject: Re: Importing New Branches into WEAP from Excel Posted: 4/28/2016 Viewed: 13376 times
You can use the WEAP Application Programming Interface (API) to automate the adding of branches. See the WEAP help topic for more information: Advanced Topics \ Automating WEAP (API).
Here's the Visual Basic Script (VBS) code you use to create 1000 branches, named with sequential numbers:
Set ParentBranch=WEAP.Branch("\Key Assumptions")
For i = 1 to 1000
Set NewBranch = ParentBranch.AddChild("Branch " & i)
If you have the names of the new branches in an Excel spreadsheet, you could use Excel's Visual Basic for Applications (VBA) language to write a simple macro that would create branches using names from Excel cells. For more information on controlling WEAP from Excel, see the Help topic: Advanced Topics \ Automating WEAP (API) \ Exploring the API.
Dr. Vignesh Sridharan
Subject: Re: Importing New Branches into WEAP from Excel Posted: 5/9/2016 Viewed: 13321 times
Thanks for the help. It definitely reduces a lot of downtime.
Eng. iman Ebrahim Bakhshipour
Subject: Re: Importing New Branches into WEAP from Excel Posted: 6/10/2019 Viewed: 6529 times
i want to know how can set a content for key assumptions by vba? for example we can do that by such command for other variables: WEAP.BranchVariable("\Demand Sites\South City:Consumption").Expression = "30"
but how can we address a key assumption?
Mr. Jack Sieber
Subject: Re: Importing New Branches into WEAP from Excel Posted: 6/10/2019 Viewed: 6522 times
Because Key Assumption and Other Assumption branches do not have variable tabs, you do not need to give a variable name when referencing them.
For example, to change the population growth rate assumption in Weaping River Basin, here is the VB code:
Subject: Re: Importing New Branches into WEAP from Excel Posted: 6/16/2019 Viewed: 6456 times
but i have one more question
are there any way to set different content for each months as what we do in 'monthly time-series wizard' ,from excel?
same what we do for resualt value: 'WEAP.ResultValue("\Supply and Resources\River\Weaping River\Reservoirs\Central Reservoir:Storage Volume[Million]", 2017, 7, "Reference").
i do not want to do it by 'readfromfile wizard' ,because it's very time-consuming in optimization model that i want to develop it.
Topic "Importing New Branches into WEAP from Excel"