Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

Generating a WMF of an Excel chart?

641 views
Skip to first unread message

Adam Lubell

unread,
Feb 19, 1997, 3:00:00 AM2/19/97
to

How do I generate a Windows Metafile (WMF), or some other type of device
independant vector graphics file from an Excel Chart?

I don't want to use Objects, or printing to Postscript, since my printer
can't handle it.

I've gone through the Help, etc, and found a way to copy a chart as a
Metafile between programs. But I'd like to be able to save the
Metafile as a FILE, so that I can import it into other software as a
LINK and keep my file sizes small.

Any suggestions appreciated.

Please e-mail response as well as posting.


Thanks,
Adam

Adam Lubell

unread,
Feb 20, 1997, 3:00:00 AM2/20/97
to 10407...@compuserve.com

Stephen Bullen wrote:
>
> Hi Adam
>
> The easiest way is to buy Office 97 and use the Export method of the
> chart object. I'm not sure if WMF is supported, but I know that
> jgp, gif and wpg are:
>
> Sub SaveAsJPG()
>
> Charts("Chart 1").Export filename:="c:\mydir\mychart.jpg",
> filtername:="jpg"
>
> End Sub
>
> Regards
>
> Stephen Bullen, Excel MVP
> http://ourworld.compuserve.com/homepages/Stephen_Bullen


Thanks for your suggestion Stephen, but....

I've got Office 97. Not quite sure how to implement your suggestion.

I've not done a lot of VBA programming, and that's how I interpret what
you're suggesting.

Can I simply put the above statements into a Macro, accessible from a
drop down menu, or am I missing something obvious? Is the "Export"
function already accessible somehow. I can't find it anywhere.

Thanks,

Adam
lub...@civil.ubc.ca
www.civil.ubc.ca/home/lubell

Stephen Bullen

unread,
Feb 20, 1997, 3:00:00 AM2/20/97
to

Stephen Bullen

unread,
Feb 21, 1997, 3:00:00 AM2/21/97
to

Hi Adam

<< Can I simply put the above statements into a Macro, accessible
from a
drop down menu, or am I missing something obvious? Is the "Export"
function already accessible somehow. I can't find it anywhere. >>

Firstly, if you have installed the html extensions from the CD, you
should have a "Save as html" item on your File menu. If so, saving
your page will export your chart as a jpg or gif image. This may be
the easiest thing to do.

My suggestion was to write your own VBA routine to do the exporting.
To do this:

Click on Tools, Macro, Record New Macro

Give the macro the name of ExportChart and choose to create it in the
Personal Macro Workbook. Click on OK.

Excel will do a few things, finally displaying the "Stop recording"
toolbar on the screen. Click on the Stop Recording button.

Now click on Tools, Macro, Visual Basic Editor. In the top-left
window, expand the + boxes to show:

- VBAProject(PERSONAL.XLS)
+ Microsoft Excel objects
- Modules
Module1

Double-click on the Module1 to bring up the code in the right-hand
window. You can see that Excel has created an empty macro for us to
put some code in.

Between the Sub.... and End Sub lines, add a blank line and put the
following:

On Error Resume Next
ActiveChart.Export FileName:=Application.GetSaveAsFilename

Click on File, Close and return to Excel.

Now click on View, Toolbars, Customize. In the Toolbars tab,
clear the tick mark next to Worksheet menu bar and put a tick next to
Chart menu bar. In the Customize box, select the Commands tab,
scroll down the categories list to Macros and select it. From the
right-hand pane, drag the text "Custom menu item" over the Tools menu
item (to bring up the list of items) and drop it somewhere on the
tools menu (e.g. at the bottom <g>). Right-click on the menu item
you just added. At the top of the pop-up menu you can change the
text of the menu (e.g. to Export Chart), and at the bottom, you can
assign a macro to it. When you click on Assign macro, you will be
shown a list of available macros, of which the ExportChart macro is
one. Select it and click OK and close the Customize box.

Now to test it, create a chart, select the chart and click on Tools,
Export Chart. You will be asked for a file name, and Excel will
export the chart to that file.

If you like, you could move the menu item to the File menu, if you
think it is more appropriate.

Regards

Stephen Bullen

0 new messages