VB Virgin

I have been asked to write a macro that exports an excel chart and converts it to a gif file.  I said yes, but to what, I did not know...

Can someone help me?  I know nothing about vb (nothing being the key word).

Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Shahid ThaikaSole ProprietorCommented:
You can try looping through all the columns and rows of the excel chart and print it to a picturebox control. Then you can save the image of the picture box control.

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
Personally, if you've got $40 to spare, I'd look up the print-to-image driver at http://www.zan1011.com/feature_bitmap.htm.  Then you can print your chart to a bmp file, which can be easily converted to a gif.  

Or, add a Microsoft Office Chart control to a form, load your chart to it and use the following librbary to copy an area to the clipboard:  http://www.vbcode.com/asp/showzip.asp?ZipFile=capbit.zip&theID=165.  Then you can paste that into an image area

Or, view your chart in Excel, select the chart and copy it (or press Alt+PrtSc to copy the Excel window) to the clipboard and paste into something like IrfanView: http://www.irfanview.com

It's really not the easiest thing in the world to do in VB...

Actually, thanks to the miracle that is the Excel Object, you can do this quite nicely as a VBA macro.  The following will export to a gif file, given the filename to export to and the Chart name (must be a separate Chart -- not embedded into a sheet):

    Sub ExportToGif

          Charts(InputBox("Chart sheet to export")).Export InputBox("File to create"), "GIF"

    End Sub
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Visual Basic Classic

From novice to tech pro — start learning today.

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.