Saving A Range As A Graphic File
Category: Charts & Graphics / General VBA | [Item URL]
Quite by accident, I discovered something today that I should have known a long time ago: When you copy an Excel range, a graphic image of that range is also stored on the Windows clipboard. As a result, you can paste the clipboard contents into most graphics programs.
It's pretty simple:
- Select a cell or range.
- Press Ctrl+C to copy.
- Activate a graphics program and press Ctrl+V to paste the image.
- Then you can save it to the graphics file format of your choice.
I tried this with IrfanView and Adobe Photoshop Elements, and it works great. There are, of course, many screen capture programs available that are more flexible, but this method is quick and easy.
Here's a simple little VBA macro that automates the first three steps:
Sub CopyAsGraphic()
Const Viewer As String = "C:\Program Files\IrfanView\i_view32.exe"
Selection.Copy
Shell Viewer, 1
Application.SendKeys "^v"
End Sub
Note: If you don't have IrfanView (or if it's in a different directory), you'll need to modify the Viewer constant. By the way, I highly recommend IrfanView as your default image viewer. It's free, fast, and feature-packed.
Start by selecting a range, a chart, a shape -- or anything else that's selectable in Excel. Then execute the CopyAsGraphic macro. IrfanView (or your other program) will appear with the copied data. Then you can do whatever you want with it.
By the way, copying is a what-you-see-is-what-you-get thing. For example, if
the selected range contains a chart, the chart will also appear in the image.
Excel Tips
Excel has a long history, and it continues to evolve and change. Consequently, the tips provided here do not necessarily apply to all versions of Excel.
In particular, the user interface of the most recent version, Excel 2007, is vastly different from its predecessors. Therefore, the menu commands listed in older tips, will not correspond to the Excel 2007 user interface.
All Tips
Browse Tips by Category
Search for Tips
Tip Books
Needs tips? Here are two books, with nothing but tips:
Contains more than 200 useful tips and tricks for Excel 2007 | Other Excel 2007 books | Amazon link: John Walkenbach's Favorite Excel 2007 Tips & Tricks
Contains more than 200 useful tips and tricks for Excel | Other Excel 2003 books | Amazon link: John Walkenbach's Favorite Excel Tips & Tricks

