+ Reply to Thread
Results 1 to 6 of 6

Save an Image with VBA

  1. #1
    Forum Contributor
    Join Date
    11-14-2009
    Location
    Midwest
    MS-Off Ver
    Excel 2003/2007
    Posts
    103

    Save an Image with VBA

    Hey all,
    I am using Excel to make several hundred images and currently have to copy paste the images into paint, then cut it, then paste into a program like paint.NET and save. It has been very tedious so far. Is there any way to simply save a range as a .png, .jpg, or .bmp? I am currently using .png files to call the images into another Excel sheet so that would be preferable. I have this code already:
    Please Login or Register  to view this content.
    This creates a new chart with the image in it then saves the chart as an image, but the image is of the entire sheet, not just the image selected. I would like to have just the selection become the image if at all possible. Thanks!

  2. #2
    Valued Forum Contributor Macdave_19's Avatar
    Join Date
    03-14-2007
    Location
    Birmingham, England
    MS-Off Ver
    12.0
    Posts
    808

    Re: Save an Image with VBA

    sorry had an idea but decided against it
    Last edited by Macdave_19; 02-22-2012 at 12:51 PM.
    Mr MaGoo
    Magoo.Inc MMVII

    If i've helped please add to my Rep by Clicking on the Blue Scales in the top right hand corner of the post

  3. #3
    Forum Contributor
    Join Date
    02-08-2012
    Location
    South Suffolk
    MS-Off Ver
    Excel 2007
    Posts
    102

    Re: Save an Image with VBA

    I have used the following code to export graphs successfully hundreds of times - it writes to a temporary folder (the global variable gsFulTempPath). The graph image is then used in the construction of an email. The other global constant is gsIMAGETYPE which is set to "png". Note the filter.
    Please Login or Register  to view this content.
    Hope this helps

  4. #4
    Forum Contributor
    Join Date
    11-14-2009
    Location
    Midwest
    MS-Off Ver
    Excel 2003/2007
    Posts
    103

    Re: Save an Image with VBA

    I guess I'm not sure how to run that code AndyPS. What specifies the range that it makes into the file?

  5. #5
    Forum Expert royUK's Avatar
    Join Date
    11-18-2003
    Location
    Derbyshire,UK
    MS-Off Ver
    Xp; 2007; 2010
    Posts
    26,200

    Re: Save an Image with VBA

    This might help
    Hope that helps.

    RoyUK
    --------
    For Excel Tips & Solutions, free examples and tutorials why not check out my web site

    Free DataBaseForm example

  6. #6
    Forum Contributor
    Join Date
    11-14-2009
    Location
    Midwest
    MS-Off Ver
    Excel 2003/2007
    Posts
    103

    Re: Save an Image with VBA

    I don't see how that does anything different than the code I already have. I guess it would work to export a chart as an image, and it's already doing that, it's just that the image is only a part of a large chart. The entire chart exports as an image, so I end up with a bunch of white space. Is there a way to ensure that the chart is exactly the dimensions of a selected image?

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1