I'm trying to automate export of energy demand by branch and fuel, but for tech branches with multiple fuels. For example, if I have a stock technology with multiple fuels (e.g. natural gas furnace which burns natural gas and biogas) has anyone been able to automate export of the fuel burn within each branch type? I found a script posted previously for automating fuel demand at the technology branch level, which is very helpful - I'd like to go one level detail if possible, but I'm not sure how to do so. Here is the script which automates export at the tech branch level:
'============================================
' Instantiate objects
' ============================================
If Not IsObject(LEAP) Then
set LEAP = CreateObject("Leap.LEAPApplication")
End If
set xla = CreateObject("Excel.Application")
' ============================================
dim tech_branches
set tech_branches = CreateObject("Scripting.Dictionary")
'dim tagnames, taggroups As String
set xlw = xla.Workbooks.Add
For i = 2 to Leap.Regions.Count
Leap.Regions(i).Active = True
V = Leap.Regions(i).Active
tech_branches.RemoveAll
for each b in LEAP.Branches
if b.Branchtype = 4 then
tech_branches.Add b.BranchID, b.FullName
end if
next
xla.Visible = true
xla.ScreenUpdating = true
LEAP.Verbose = 4
LEAP.Visible = true
set xls = xla.sheets.add
xls.name = LEAP.Regions(i).Name
' Add headers to Excel worksheet
r = 1
xls.Cells(r, 1).Value = "Scenario"
xls.Cells(r, 2).Value = "Year"
xls.Cells(r, 3).Value = "Branch"
xls.Cells(r, 4).Value = "Region"
xls.Cells(r, 5).Value = "Energy"
LEAP.ActiveView = "Results"
For s = 4 to 4
LEAP.Scenarios(s).Active = true
for y = LEAP.BaseYear to LEAP.EndYear
for each item in tech_branches.items
r = r + 1
xls.Cells(r, 1).Value = s
xls.Cells(r, 2).Value = y
xls.Cells(r, 3).Value = LEAP.Branch(item).FullName
xls.Cells(r, 4).Value = LEAP.Regions(i).Name
xls.Cells(r, 5).Value = LEAP.Branch(item).Variable("Energy Demand Final Units").Value(y, "Million BTU")
next
next
next
next
xla.screenupdating = true
xla.visible = true
LEAP.ActiveView = "Analysis"