A Microsoft Office (Excel, Word) forum. OfficeFrustration

If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

Go Back   Home » OfficeFrustration forum » Microsoft Excel » Charts and Charting
Site Map Home Register Authors List Search Today's Posts Mark Forums Read  

Save chart as 800x600 GIf



 
 
Thread Tools Display Modes
  #1  
Old August 20th, 2009, 09:39 AM posted to microsoft.public.excel.charting
Fan924
external usenet poster
 
Posts: 17
Default Save chart as 800x600 GIf

I found this and it works well. Exports charts as a gif image. I have
had no luck controlling the sixe of the GIF. What can I add to force
the GIF ouput to a 800x600 size?


Sub Save_ChartAsGif()
Dim oCht As Chart
Set oCht = ActiveChart
'ActiveSheet.Name
On erRROR GoTo Err_Chart
oCht.Export FileName:="D:\My Documents\_wip\Pic_" & ActiveSheet.Name &
".gif", Filtername:="gif"
'oCht.Export FileName:="C:\PopularICON.jpg", Filtername:="JPG"
Err_Chart:
If Err 0 Then
Debug.Print Err.Description
Err.Clear
End If
End Sub
  #2  
Old August 20th, 2009, 07:01 PM posted to microsoft.public.excel.charting
Jon Peltier[_2_]
external usenet poster
 
Posts: 386
Default Save chart as 800x600 GIf

You need to make the chart the proper size in Excel prior to exporting
it. That means it must already be 800x600.

There are 96 pixels per inch in a typical Windows setup (but it might be
different on yours, who knows). This means the image has to be 8.33x6.25
inches. You can set this if you shift click to select the chart (shift
click selects the chart object and puts white handles on the corners,
not black ones). Then on the Format menu, choose Objects..., and on the
size tab of the dialog, enter this size in inches.

In code, you can resize the chart into points (72 points/inch, or 0.75
points/pixel). You need it to be 600x450 points.

Sub Save_ChartAsGif()
Dim oCht As Chart
Set oCht = ActiveChart
'ActiveSheet.Name
On Error GoTo Err_Chart

'------------------------
' resize the chart object
oCht.Parent.Width = 600
oCht.Parent.Height = 450
'------------------------

oCht.Export FileName:="D:\My Documents\_wip\Pic_" & ActiveSheet.Name _
& ".gif", Filtername:="gif"
'oCht.Export FileName:="C:\PopularICON.jpg", Filtername:="JPG"
Err_Chart:
If Err 0 Then
Debug.Print Err.Description
Err.Clear
End If
End Sub

- Jon
-------
Jon Peltier
Peltier Technical Services, Inc.
http://peltiertech.com/



Fan924 wrote:
I found this and it works well. Exports charts as a gif image. I have
had no luck controlling the sixe of the GIF. What can I add to force
the GIF ouput to a 800x600 size?


Sub Save_ChartAsGif()
Dim oCht As Chart
Set oCht = ActiveChart
'ActiveSheet.Name
On erRROR GoTo Err_Chart
oCht.Export FileName:="D:\My Documents\_wip\Pic_" & ActiveSheet.Name &
".gif", Filtername:="gif"
'oCht.Export FileName:="C:\PopularICON.jpg", Filtername:="JPG"
Err_Chart:
If Err 0 Then
Debug.Print Err.Description
Err.Clear
End If
End Sub

  #3  
Old August 20th, 2009, 10:50 PM posted to microsoft.public.excel.charting
Fan924
external usenet poster
 
Posts: 17
Default Save chart as 800x600 GIf

Something is missing. It no longer saves a file.

  #4  
Old August 20th, 2009, 11:31 PM posted to microsoft.public.excel.charting
Fan924
external usenet poster
 
Posts: 17
Default Save chart as 800x600 GIf

Thanks Jon, my error. It works fine on a chart in a excel file. I had
a chart as a stand alone which was not recizable. Thanks for your help.
 




Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Forum Jump


All times are GMT +1. The time now is 04:41 AM.


Powered by vBulletin® Version 3.6.4
Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 OfficeFrustration.
The comments are property of their posters.