Saving a graph as .jpg

H

haisat

Hi,
I am trying to plot a graph using Macro and could do that. But I have
to store that graph as a .jpg or .gif file. Is there any way i could do
that automatically(like macro)? Could anybody help me in doing this.
 
J

J.E. McGimpsey

If you save the file as a web page, the graph will automatically be
saved as a .gif.

For instance, if you save the one-sheet workbook foo.xls as a web
page, the graph will be saved in the foo_files directory (which is
at the same level as foo.htm) as image001.gif.
 
H

haisat

Hi,
Thanks for your answer but I didnt get exactly what you said. First i
saved the file as .xls and then how to save as webpage? one more
question is it possible to make this automation(through Macro or some
other way)?
 
J

J.E. McGimpsey

You needn't save it as an .xls file first. Manually: Use File/Save
As Web Page (or choose Web Page from the File/Save As dialog's
Format dropdown).

Programmatically: try recording a macro of saving as a web page, and
modifying from there. Post back with your code if you need help.
 
H

haisat

Hi,
To be frank I couldnt find any option to save as Web page in my Excel.
I am using Excel 97. Is it newly added with 2000?
 
T

Tom Ogilvy

Note that you will need SR1 at least to do it programmatically and I don't
believe recording will work.

But you may want to look at this first:

http://support.microsoft.com/?id=163103
How to Create a GIF File from a Microsoft Excel Chart

for a JPG I did:
Sub Create_JPG()
Dim mychart As Chart
Set mychart = ActiveSheet.ChartObjects(1).Chart
mychart.Export Filename:="F:\Mychart.jpg", FilterName:="JPG"
End Sub

and it worked for me.

If you still want to go the Save As Html route in VBA:

Microsoft Information on VBA and HTML:

http://office.microsoft.com/downloads/9798/html.aspx
http://www.microsoft.com/downloads/...06-10A0-42B6-83B2-B21B83E66BD9&displaylang=EN
Internet Assistant Wizard Update for Excel

http://support.microsoft.com/?id=147273
XL: The Internet Assistant Wizard (Html.xla)
(basically redundant to the above)

http://support.microsoft.com/?id=168561
XL97: How to Programmatically Save a Worksheet as HTML
(Has sample code)


http://support.microsoft.com/?id=172165
XL97: Error Creating Web Page with Option Base 1 Setting

http://support.microsoft.com/?id=172305
XL97: LastUpdated Argument of Htmlconvert Is Not Functional
(Has sample code)

http://support.microsoft.com/support/excel/content/excel97/xlweb.asp
Microsoft Excel 97 on the Web

http://support.microsoft.com/support/excel/content/webformwizard/webform3.asp
Creating a Form to Use With the Web Form Wizard

http://support.microsoft.com/?id=150004
MS Excel Internet Assistant Wizard: Removing Gridlines in HTML

http://support.microsoft.com/?id=163103
How to Create a GIF File from a Microsoft Excel Chart

I haven't checked the links in a while - hopefully they all still work.

--
Regards,
Tom Ogilvy


jaf said:
No, You need to do tools>add-ins, check the internet assistant.
 
D

Don Guillett

for gif just change reference to .jpg to .gif
Sub ExportChartGIF()
ActiveChart.Export Filename:="C:\a\MyChart.gif",FilterName:="GIF"
End Sub

David McRitchie said:
ActiveChart.Export FileName:="D:\MyChart.jpg", FilterName:="JPEG"

also see Harold Staff's write up in
XL2GIF routine
ttp://www.mvps.org/dmcritchie/excel/xl2gif.htm
which places picture of a group of cells onto a graph so it can create
a .jpeg file.

HTH,
David McRitchie, Microsoft MVP - Excel [site changed Nov. 2001]
My Excel Pages: http://www.mvps.org/dmcritchie/excel/excel.htm
Search Page: http://www.mvps.org/dmcritchie/excel/search.htm

haisat said:
I am trying to plot a graph using Macro and could do that. But I have
to store that graph as a .jpg or .gif file. Is there any way i could do
that automatically(like macro)? Could anybody help me in doing this.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top