• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 174
  • Last Modified:

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).

  • 2
1 Solution
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.
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

Featured Post

The new generation of project management tools

With monday.com’s project management tool, you can see what everyone on your team is working in a single glance. Its intuitive dashboards are customizable, so you can create systems that work for you.

  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now