• 412 views | 5 messages Discussion: LEAP
    Topic: Problem "Exploring the API Using MS-Excel" Subscribe | Previous | Next
  • Ralph Samuelson 6/2/2011

    2482 Views

    I have been trying to follow the instructions in the Help screen "Exploring the API Using MS-Excel". It says "In Excel, first create a new blank workbook, then go to Tools: Macros: Visual Basic Editor." Did that. Actually, in my Excel 2007 you first have to go to "Tools"->"Macros"->"View Macros" to open the macro editor, then enter a macro name and click "Create" to open the Visual Basic Editor. But I got there.

    Then it says "Now go to Tools, References. Scroll down to find "LEAP" and make sure the check box is checked." Unfortunately, although there is a long list of Available References, I don't find "LEAP" on the list. What am I doing wrong?


  • Tory Clark 6/2/2011
      Best Response

    2478 Views

    Hi Ralph,

    My guess is that LEAP has not been registered as an element within Excel.

    The way to do this manually is to locate your LEAP program files folder (likely C:\Program Files\LEAP or C:\Program Files\LEAP2011) and open a command prompt there.

    NB: In Vista and Windows 7 you can open a command prompt directly from a folder by holding the shift key and right clicking.

    Then type the following:

    LEAP /regserver

    You can also type the full command including folder into the command prompt (which might be easier if using XP), remembering to use the path of your program files folder. For me, the entire command looks like this:

    C:\Program Files\LEAP2011>leap /regserver

    This should register the LEAP API correctly and then you should be able to see "LEAP API" in the list of available references.

    Please let me know if this does not work.

    Best,

    Tory
  • Ralph Samuelson 6/6/2011
      Best Response

    2465 Views

    Thanks, Tory, that did seem to solve the problem with the API.

    I am now trying to run a simple script in the Script Editor to export some LEAP results to an Excel file. The script is as follows:

    LEAP.ActiveArea = "Viet Nam 1"
    LEAP.ActiveScenario = "BAU"
    LEAP.ActiveView = "Analysis"
    LEAP.ActiveBranch="Transformation\Electricity\Generation\Processes"
    LEAP.ActiveVariable="Transformation:Inputs"
    LEAP.ExportResultsXLS("Tab1")

    The script runs without errors and exports a nice table of results to Excel, but it is not the table for the "Transformation\Electricity\Generation\Processes" branch, nor is the variable "Transformation:Inputs". It seems to ignore these settings and just exports whatever table I last viewed manually in LEAP.

    Any ideas what I might be doing wrong?




  • Tory Clark 6/6/2011
      Best Response

    2463 Views

    Hi Ralph,

    There are a few things going on here.

    1. You need to be in results view to export results (i.e. set LEAP.ActiveView to "Results").

    2. At this time you cannot reference a result by branch name or path. Instead you must reference a result as a favorite chart using LEAP.Favorite("FavoriteName").

    3. You can change various chart parameters only after you have pointed to a favorite in your script.

    For example, the following script will export the results from a single pre-created Favorite Chart called Inputs :

    LEAP.ActiveArea = "Viet Nam 1"
    LEAP.ActiveView = "Results"
    LEAP.Favorite("Inputs").Activate
    LEAP.ExportResultsXLS("Tab1")

    The following script will export the Inputs favorite in both BAU and Mitigation Scenarios:

    LEAP.ActiveArea = "Viet Nam 1"
    LEAP.ActiveView = "Results"
    LEAP.Favorite("Inputs").Activate
    LEAP.ActiveScenario = "BAU"
    LEAP.ExportResultsXLS("BAU Inputs")
    LEAP.ActiveScenario = "Mitigation"
    LEAP.ExportResultsXLS("Mitigation Inputs")


    Best,

    Tory
  • Ralph Samuelson 6/7/2011
      Best Response

    2456 Views

    Thanks, Tory. We will give this a try. Ralph