Subject: Scripting Posted: 5/2/2011 Viewed: 21200 times
I am trying to run a VB script with WEAP, at the end of the calculations.
The objective of the script is to write various results (flow data for instance) in an external Excel file.
The script works very well if I ask to copy 100 values to my Excel sheet. But as soon as I ask to copy more values, it stops during the execution and an error message tells me that there is a "Unknown runtime error".
I don't think that this is a problem of the "Sript Timeout" factor because I tried to change it without success.
Does anybody also face similar problem and does anybody know how to solve it?
Thank you very much for your attention. I can send more details on demand.
Julien VERDONCK, currently in Chad.
Subject: Re: Scripting Posted: 5/2/2011 Viewed: 21199 times
Can you please send me a copy of the WEAP area so that I can try to reproduce the error?
Subject: Re: Scripting Posted: 5/9/2011 Viewed: 21158 times
I would also like to export stream flow results to an excel file. Unfortunately I have zero background in VB and am in the process of learning how to use it. Would it be possible to have a copy of your script? that would greatly assist me in understanding how it works.
Subject: Re: Scripting Posted: 5/25/2011 Viewed: 21075 times
Thank you very much for your prompt answer and sorry for my late reply. Internet was very bad in Chad.
The script was in fact ok and my mistake was to touch the excel file while WEAP was filling it. Indeed, touching the Excel file while WEAP is working on it immediately stops the script.
Now I have added to the script a message box which tells me when the run is completed.
Subject: Re: Scripting Posted: 5/25/2011 Viewed: 21072 times
Please find below an extract of my script.
It will open the file "C:\XXX\Excel_file.xls" and the sheet "Name_of_the_sheet" and write in a column the monthly streamflows of the WEAP branch (to be changed according to your model) "Supply and Resources\River\Chari\Reaches\Below Return Flow Node 28".
The time step I use is the monthly time step.
for my_year=1950 to 2000
for my_month=1 to 12
my_cell.value=WEAP.Branch("Supply and Resources\River\Chari\Reaches\Below Return Flow Node 28").Variables("Streamflow").Value(my_year,my_month)
Subject: Re: Scripting Posted: 5/26/2011 Viewed: 21062 times
Many thanks for the script!