Using PastePicture Code?

  • Thread starter Thread starter Tammy Coxen
  • Start date Start date
T

Tammy Coxen

Andy Pope pointed me towards Stephen Bullen's PastePicture code as a way to
export metafile graphics from Excel. But I'm a total VBA dummy - can
someone please help me figure out how to make this work with my own charts?

Thanks,
Tammy
 
Andy Pope pointed me towards Stephen Bullen's PastePicture code as a
way to export metafile graphics from Excel. But I'm a total VBA dummy
- can someone please help me figure out how to make this work with my
own charts?

You could also use the ASAP utilities add-in:

http://www.asap-utilities.com/

ASAP/Export produces good quality pictures of graphs in several formats.
 
Hi Tammy,

Add this routine to a new code module in Stephen's PastePicture
workbook. Then select a chart and run the routine ExportEMF.

'-------------------------------
Sub ExportEMF()

Dim vFile As Variant
Dim sFilter As String
Dim lPicType As Long
Dim oPic As IPictureDisp

'Create filter
sFilter = "Windows Metafile (*.emf),*.emf"

'Get the filename to save the bitmap to
vFile = Application.GetSaveAsFilename(initialfilename:="", _
filefilter:=sFilter)

If vFile <> False Then
'Get the type of bitmap
lPicType = xlPicture

'Copy a picture on the chart with the correct format to the clipboard
ActiveChart.CopyPicture xlScreen, lPicType, xlScreen

'Retrieve the picture from the clipboard...
Set oPic = PastePicture(lPicType)

'... and save it to the file
SavePicture oPic, vFile
End If

End Sub
'-------------------------------

Cheers
Andy
 
Back
Top