511 Views
I have a huge problem with the LEAP API in Excel, whit no solution in sight. It's a general problem, by I'll explain it by using the example code below
---------------
'Option Explicit
Dim Fuel_counter As Integer
Dim scenario_counter As Integer
Dim area_name As String
Dim scenario_name As String
Dim fuel_name As String
Sub LEAP_Extractor()
Set L = CreateObject("LEAP.LEAPApplication") 'Opens LEAP and sets "L" to use objects for
area_name = Range("A3").Value
Worksheets("Energy Demands").Cells(1, 1) = area_name
L.ActiveArea = area_name ' Set ActiveArea to area_name DOESN'T WORK!!!???
L.Calculate (False) 'Calculates the LEAP Area and sets the viewing pane to "Results"
End Sub
--------------
I want the ability for the user to choose, and use Excel lists, for variables. Doing this in VBA you input a reference to a cell or range for the code to read.
In the above sample code, I do this with area_name, it could have been scenarios, branches, etc. All good. Now I want LEAP objects (in this case ActiveArea) to read it in my Sub.
No dice, LEAP error: "LEAP.ActiveArea: Cannot set active area to nothing". Cannot do "area_name" in the VBA, because then LEAP thinks the name is area_name, which yields another error...
Again, this error is for all "ActiveXxxx" variables. How can I set variables if I cannot reference them, or have I missed something?
For various reasons, I have no interest in using LEAPs script editor, opting rather for VBA. I think the problem persists there too, what I can tell.
Hope you can help,
Gregers