I often build graphs frame-by-frame (point-by-point) in Excel and then use VBA to export the graph as an image as I change the value of a cell that advances the graph by one increment.
Here's a sample graph (adjust cell A1 to see what I mean):
http://amhx.net/graph.ods
I used the following mess of a code to save the workbook as an HTML file and then it gives me the jpgs of the graph. Before I paste the miles of code (which I got by recording a macro and then tweaking), here's the output for which I'm trying to get:

I'll just end up deleting the .html files and saving the pictures which I can stitch together in AfterEffects (side question...is there a Linux tool to stitch images into an .MP4?)
And here's the OOCalc code I use:
Code: Select all
sub Main
dim document as object
dim dispatcher as object
document = ThisComponent.CurrentController.Frame
dispatcher = createUnoService("com.sun.star.frame.DispatchHelper")
dim args1(0) as new com.sun.star.beans.PropertyValue
args1(0).Name = "ToPoint"
args1(0).Value = "$A$1"
dispatcher.executeDispatch(document, ".uno:GoToCell", "", 0, args1())
dim args2(2) as new com.sun.star.beans.PropertyValue
args2(0).Name = "URL"
args2(0).Value = "file:///C:/TEMP/01.html"
args2(1).Name = "FilterName"
args2(1).Value = "HTML (StarCalc)"
args2(2).Name = "FilterOptions"
args2(2).Value = ""
dispatcher.executeDispatch(document, ".uno:SaveAs", "", 0, args2())
dim args3(0) as new com.sun.star.beans.PropertyValue
args3(0).Name = "ToPoint"
args3(0).Value = "$A$1"
dispatcher.executeDispatch(document, ".uno:GoToCell", "", 0, args3())
dim args4(0) as new com.sun.star.beans.PropertyValue
args4(0).Name = "StringName"
args4(0).Value = "2"
dispatcher.executeDispatch(document, ".uno:EnterString", "", 0, args4())
dim args5(1) as new com.sun.star.beans.PropertyValue
args5(0).Name = "By"
args5(0).Value = 1
args5(1).Name = "Sel"
args5(1).Value = false
dispatcher.executeDispatch(document, ".uno:GoUp", "", 0, args5())
dim args6(2) as new com.sun.star.beans.PropertyValue
args6(0).Name = "URL"
args6(0).Value = "file:///C:/TEMP/02.html"
args6(1).Name = "FilterName"
args6(1).Value = "HTML (StarCalc)"
args6(2).Name = "FilterOptions"
args6(2).Value = ""
dispatcher.executeDispatch(document, ".uno:SaveAs", "", 0, args6())
dim args8(0) as new com.sun.star.beans.PropertyValue
args8(0).Name = "ToPoint"
args8(0).Value = "$A$1"
dispatcher.executeDispatch(document, ".uno:GoToCell", "", 0, args8())
dim args9(0) as new com.sun.star.beans.PropertyValue
args9(0).Name = "StringName"
args9(0).Value = "3"
dispatcher.executeDispatch(document, ".uno:EnterString", "", 0, args9())
dim args10(1) as new com.sun.star.beans.PropertyValue
args10(0).Name = "By"
args10(0).Value = 1
args10(1).Name = "Sel"
args10(1).Value = false
dispatcher.executeDispatch(document, ".uno:GoUp", "", 0, args10())
dim args11(2) as new com.sun.star.beans.PropertyValue
args11(0).Name = "URL"
args11(0).Value = "file:///C:/TEMP/03.html"
args11(1).Name = "FilterName"
args11(1).Value = "HTML (StarCalc)"
args11(2).Name = "FilterOptions"
args11(2).Value = ""
dispatcher.executeDispatch(document, ".uno:SaveAs", "", 0, args11())
dim args14(0) as new com.sun.star.beans.PropertyValue
args14(0).Name = "ToPoint"
args14(0).Value = "$A$1"
dispatcher.executeDispatch(document, ".uno:GoToCell", "", 0, args14())
dim args15(0) as new com.sun.star.beans.PropertyValue
args15(0).Name = "StringName"
args15(0).Value = "04"
dispatcher.executeDispatch(document, ".uno:EnterString", "", 0, args15())
dim args16(1) as new com.sun.star.beans.PropertyValue
args16(0).Name = "By"
args16(0).Value = 1
args16(1).Name = "Sel"
args16(1).Value = false
dispatcher.executeDispatch(document, ".uno:GoUp", "", 0, args16())
dim args17(2) as new com.sun.star.beans.PropertyValue
args17(0).Name = "URL"
args17(0).Value = "file:///C:/TEMP/04.html"
args17(1).Name = "FilterName"
args17(1).Value = "HTML (StarCalc)"
args17(2).Name = "FilterOptions"
args17(2).Value = ""
dispatcher.executeDispatch(document, ".uno:SaveAs", "", 0, args17())
rem ----
dim args18(0) as new com.sun.star.beans.PropertyValue
args18(0).Name = "ToPoint"
args18(0).Value = "$A$1"
dispatcher.executeDispatch(document, ".uno:GoToCell", "", 0, args18())
dim args19(0) as new com.sun.star.beans.PropertyValue
args19(0).Name = "StringName"
args19(0).Value = "05"
dispatcher.executeDispatch(document, ".uno:EnterString", "", 0, args19())
dim args20(1) as new com.sun.star.beans.PropertyValue
args20(0).Name = "By"
args20(0).Value = 1
args20(1).Name = "Sel"
args20(1).Value = false
dispatcher.executeDispatch(document, ".uno:GoUp", "", 0, args20())
dim args21(2) as new com.sun.star.beans.PropertyValue
args21(0).Name = "URL"
args21(0).Value = "file:///C:/TEMP/05.html"
args21(1).Name = "FilterName"
args21(1).Value = "HTML (StarCalc)"
args21(2).Name = "FilterOptions"
args21(2).Value = ""
dispatcher.executeDispatch(document, ".uno:SaveAs", "", 0, args21())
end sub
In Excel, it's really easy!:
Code: Select all
Sub ExportChart()
Dim objChrt As ChartObject
Dim myChart As Chart
x = 1
Sheets("Graphs").Select
Do While x <= 10
Range("A1").Select
ActiveCell.FormulaR1C1 = x
Set objChrt = Sheets("Graphs").ChartObjects("Chart 1")
Set myChart = objChrt.Chart
If x < 10 Then
myFileName = "0000" & x & ".png"
ElseIf x < 100 Then
myFileName = "000" & x & ".png"
ElseIf x < 1000 Then
myFileName = "00" & x & ".png"
ElseIf x < 10000 Then
myFileName = "0" & x & ".png"
Else
myFileName = x & ".png"
End If
On Error Resume Next
Kill ThisWorkbook.Path & "\" & myFileName
On Error GoTo 0
myChart.Export Filename:=ThisWorkbook.Path & "\" & myFileName, Filtername:="PNG"
x = x + 1
Loop
End Sub