Reputation: 574
I want to use VBA programming to save a a series of charts in Excel into one GIF picture for the animation effect. Is there any solution?
The below is a related question which address the issue of saving a chart into a GIF file one by one without any animation effect. Excel VBA - Saving Charts as GIF files
Upvotes: 2
Views: 1942
Reputation: 14112
Looks like VBA cannot export animated gifs itself, which makes for an interesting programming challenge. You have two options:
The GIF specification doesn't look hard. In fact, here's a guy who says it's easy to implement it in VBA. If you have time and are coding for learning or for fun, I'd attempt this. If you're hard pressed, try the next suggestion.
Have a free tool like Gifsicle do the job for you (download the Windows port). In your code, when it's time to create the resulting GIF, instead of something like
call CreateGif("result.gif", "input1.gif", "input2.gif", "input3.gif")
You will externally call the .exe
tool, like:
call Shell("C:\path\to\gifsicle.exe input1.gif input2.gif input3.gif > result.gif")
Note that you'll probably need to fiddle with quoting paths and generally building the command line correctly (you'll use a loop if the number of input GIFs is variable). Read Gifsicle's man page for usage details.
Upvotes: 2