• 565 views | 3 messages Discussion: LEAP
    Topic: Importing data from excel using the API Subscribe | Previous | Next
  • Marcelo Resende 8/27/2017

    Hi! I am trying to use LEAP's script editor to import data from a xlsx file. This data would be valid only for a specific scenario ("Reference Scenario"), so I tried to do the following:

      firstscenario_year = LEAP.FirstScenarioYear - 2
      end_year = LEAP.EndYear

      LEAP.Scenario("Reference Scenario").Active = TRUE

      Set Residential = LEAP.Branches("Demand").Children("Residential").Children("Charcoal")
      Set var_activity_level = Residential.Variable("Total Energy")

      Dim year
      result_expression = "Step("
      For year = firstscenario_year  To end_year
       if ( year > firstscenario_year ) Then
         result_expression = result_expression & ", "
       end if
       result_expression = result_expression & sheet_resultado.Cells(2,year-firstscenario_year+4).Value
       result_expression = result_expression & ", " & sheet_resultado.Cells(3,year-firstscenario_year+4).Value
      Next
      result_expression = result_expression & ")"

      var_activity_level.Expression = result_expression

    My problem is in the line in bold above. It is not selecting the scenario "Reference Scenario". In fact, LEAP is always filling the scenario I select before running this code (for example, if I am in the current accounts scenario, then data from the excel is pasted in Current Accounts, not in "Reference Scenario"). I have also tried to use LEAP.ActiveScenario = "Reference Scenario" and LEAP.ActiveScenario = LEAP.Scenarios("Reference Scenario"), with the same result.

    How can I select "Reference Scenario" and fill it with excel data?

    Thanks a lot!

  • Taylor Binnington 9/6/2017
      Best Response

    Hi Marcelo,

    Sorry for the trouble, and for the wait. This is indeed a problem introduced in a recent version of LEAP. For now, you will need to change scenarios manually before executing your script. 

    I'll let you know via this thread when the issue is resolved.

    Best,
    Taylor

  • Taylor Binnington 12/15/2017
      Best Response

    Hi - this has been resolved in version 2018.0.1.2. Please download the latest version of LEAP here

    Taylor