• 99 views | 2 messages Discussion: LEAP
    Topic: VB Script ErrorSubscribe | Previous | Next
  • Soeharwinto ST MT 2/8/2014

    1913 Views

    I have script below:

    On Error Resume Next
    Err.Clear 'Clears any earlier error

    Set xla = GetObject(, "Excel.Application")
    IF Err.Number > 0 THEN
    Set xla = CreateObject("Excel.Application")
    END IF

    ON ERROR GOTO 0 'This turns Off Error Handling

    xla.Visible = true
    xla.ScreenUpdating = false

    for yr = LEAP.BaseYear to LEAP.EndYear
    LEAP.ActiveYear = yr
    LEAP.ExportEnergyBalanceXLS
    next

    ShtCnt = xla.Sheets.Count
    For i = 1 to ShtCnt
    xla.Sheets(i).Name = Cstr(LEAP.EndYear + 1 - i)
    Next

    xla.Visible = true
    xla.ScreenUpdating = true


    When I run it, errors appear on line/column: 14,0; says: "Error in script: Object required:'LEAP'

    I use LEAP newest version 2012.0.0.56

    Are there something wrong with my script? Thank You in advance for your help.

    regards,
    soeharwinto
  • Taylor Binnington 2/18/2014
      Best Response

    1911 Views

    Hi Soeharwinto,

    I don't think there's anything technically wrong with your script, but it's not clear from your question where you're running the script from. For example, when I copied your script into LEAP's internal script editor (under Advanced:Edit Scripts), it ran without a problem. If your running it from something outside LEAP, make sure that the LEAP API is made available as a reference for your VBA project. In Excel's Developer view, for example, this would be accomplished by selecting Tools:references, and then ensuring that the box labeled 'LEAP API" is checked (see here for more details: http://www.energycommunity.org/WebHelpPro/API/Exploring.htm).

    Hope this helps,

    Taylor