Solved

VB Virgin

Posted on 2004-10-27
158 Views
Last Modified: 2010-05-02
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).

thanks,
jewels
0
Question by:frecha
    4 Comments
     
    LVL 9

    Expert Comment

    by:Shahid Thaika
    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.
    0
     
    LVL 29

    Accepted Solution

    by:
    0
     
    LVL 16

    Expert Comment

    by:jimbobmcgee
    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...

    J.
    0
     
    LVL 16

    Expert Comment

    by:jimbobmcgee
    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
    0

    Write Comment

    Please enter a first name

    Please enter a last name

    We will never share this with anyone.

    Featured Post

    Shellfire Box VPN + Lifetime Subscription

    The Shellfire Box easily connects all of your devices, even those that don't offer the possibility to establish a safe vpn connection. Access blocked content and surf safely, no matter where in the world you are located.

    Have you ever wanted to restrict the users input in a textbox to numbers, and while doing that make sure that they can't 'cheat' by pasting in non-numeric text? Of course you can do that with code you write yourself but it's tedious and error-prone …
    Since upgrading to Office 2013 or higher installing the Smart Indenter addin will fail. This article will explain how to install it so it will work regardless of the Office version installed.
    As developers, we are not limited to the functions provided by the VBA language. In addition, we can call the functions that are part of the Windows operating system. These functions are part of the Windows API (Application Programming Interface). U…
    Get people started with the process of using Access VBA to control Outlook using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Microsoft Outlook. Using automation, an Access applic…

    884 members asked questions and received personalized solutions in the past 7 days.

    Join the community of 500,000 technology professionals and ask your questions.

    Join & Ask a Question

    Need Help in Real-Time?

    Connect with top rated Experts

    22 Experts available now in Live!

    Get 1:1 Help Now