Excel chart exporting

  VoG™ 23:19 24 Apr 2003

I know how to export a chart as a .GIF file:

Sub GifCht()

Dim FName As String

FName = Application.InputBox(prompt:="Please enter File name", Title:="Export chart", Type:=2)

ActiveChart.Export FileName:="L:\Results\" & FName & ".gif", FilterName:="GIF"

End Sub

Dead easy!

How do I export a chart as a .BMP? There is no clue in the MS Help or Knowledgebase (correct me if I am wrong) and I can't find anything on the Eccel sites that I visit.

A forlorn hope... ?

  fitshase 23:22 24 Apr 2003

Can you not just export the chart as a GIF and then convert it to a BMP in a paint package?



  VoG™ 23:41 24 Apr 2003

Thank you, yes I can but...

I should have explained the reason. When saved as GIFs the images seem to be degraded - the colours are less vibrant and generally the image quality is poorer (I think that GIF is a lossy format?).

Anyway what I want to do is use a series of macros to export BMPs from Excel then import them into Word and Powerpoint. The loss of image quality is most noticeable in PP.

I know how to copy and paste a chart from Excel into Word manually; I need to automate this.

  tbh72 00:41 25 Apr 2003

Can you not just rename the code to produce the bmp (whatever) image, Have you played with the TYPE setting codes??

  MAJ 00:50 25 Apr 2003

What about PrintScrn, Vog™? Bit long winded though. PrintScrn > Paintshop Pro > Save as > .Bmp If you're looking for a coding answer, count me out, mate. ;-)

  MAJ 00:59 25 Apr 2003

There's a crop process missing there. It should read:

PrintScrn > Paintshop Pro > Crop > Save as > .Bmp

  penny 03:37 25 Apr 2003

Something just whizzed over my head!

  Taran 04:55 25 Apr 2003

I saw a little program years ago that would allow just what you have in mind.

Clipmeta or Clipmate or something like that - Clip something or other, sorry but it's so long ago I can't remember which.

I'll have a hunt around and see if

1. I have it on an old backup disk


2. whether it works on recent versions of Excel.

Incidentally, the excellent ASAP Utilities has a very effective export filter for charts (or named/selected range) as bitmaps in GIF, PNG and JPG.

I already know that you're a wiz at Excel VBA, but how are you with full on VB ?

I only ask because with a little jiggery pokery its possible to write and compile your own DLL(s) that can do pretty much exactly what you want to do.

It's quite involved and inconvenient to code, but once done (and backed up) you can obviously call on it any time. There's an article I found that covers much of what you would need, although it isn't precisely the same scenario you describe;

click here

A code snippet that may help you get on the right track is as follows (it also runs fine as VBA or VB):



Image1.Picture = Clipboard.GetData(vbCFBitmap)

Obviously, this is a simple select/copy routine but has a neat twist of using the Clipboard.GetData method to extract the bitmap image, saving it as the Picture property of the Image control. It's a nice trick that I've used before and you already have the necessary filters available since bitmap is included as a filter within an MS Office install.

It's pointless my offering more specific code because I'm not sure of the exact requirements here other than the general office automation/integration/import/export you outline, but it should illustrate one possible different approach.

I hope you realise you've made me post code which, until now, I've avoided at all costs since it's what I chew on at every day. I'm off to bed to sulk now...


Hope this helps a bit.



  Ben Avery 11:17 25 Apr 2003

Is it jaut a case of wanting to copy the cart as a bitmap then insertinging it into a new document (Word, PowerPoint etc)?

If so, why no just make the chart very large on the scheet, copy, paste into Paint and save the result as a bitmap?

You can then use the insert picture function in most other software to import the file without loss of colouration etc.


  Ben Avery 11:18 25 Apr 2003

Sorry didn't see your second post!


  VoG™ 15:27 25 Apr 2003

As suggested I needed to go the Copy/Paste way. For the record my (interim) solution is:

Sub SaveBmp()

Dim vFile, SFilter As String, lPicType As Long, oPic As IPictureDisp, path As String

ActiveChart.CopyPicture Appearance:=xlPrinter, Format:=xlPicture

SFilter = "Windows Bitmap (*.bmp), *.bmp"

vFile = path & "\test999.bmp"

lPicType = xlPicture

Set oPic = PastePicture(lPicType)

SavePicture oPic, vFile

End Sub

which calls PastePicture which I found click here

I'm still rather perplexed that I can create a GIF file using about 3 lines of code whilst it takes several dozen lines (including PastePicture) to save as a BMP.

I will tick as resolved but I'm still searching for a simpler solution.

This thread is now locked and can not be replied to.

Elsewhere on IDG sites

AMD Ryzen news - release date, UK price, features and specifications

The pulp art of 80s computer game magazine covers

Best value Mac: Which is the best £1249 Mac to buy

Comment faire des captures d’écran sous Windows 10 ?