Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 162
Default Export Pie Graph Chart as Image

Hi,

I am trying to export a chart to a local *.gif image and I am getting
all sorts of errors...anyone have any ideas? I have searched the boards

and I keep getting the same error message each time I try to run the
macro...


===========================
Run-time error '91':
Object variable or With block variable not set


Sub SaveChartAsGIF ()
Fname = ThisWorkbook.Path & "\" & ActiveChart.Name & ".gif"
ActiveChart.Export FileName:=Fname, FilterName:="GIF"
End Sub
===========================
Run-time error '1004'
Method 'Export' of object '_Chart' failed


Dim mychart As Chart
Set mychart = ActiveSheet.ChartObjects(1).Chart
mychart.Export Filename:="c:\Mychart.gif", FilterName:="GIF"
============================


I have tried a few other codes on the boards and they all produce one
or the other errors shown above. It wouldn't be such a problem if I
could have a macro resize the CHART WINDOW to full screen but I can't
seem to find that information anywhere...Any help is much appreciated!
Thanks so much!

  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 5,600
Default Export Pie Graph Chart as Image

To save your chart as an image find Stephen Bullen's PastePicture.zip on
this page
http://www.oaltd.co.uk/Excel/Default.htm

It wouldn't be such a problem if I
could have a macro resize the CHART WINDOW to full screen


'Locate' your chart on a Chart sheet
With the chart-sheet, File Page Setup Margins, experiment reducing
margins (reset before printing).
Put the 'Full Screen' menu item on your toolbar which you'll find under -
Customize toolbars Commands View
Do that both with a chart-sheet and worksheet active.

Regards,
Peter T

wrote in message
ups.com...
Hi,

I am trying to export a chart to a local *.gif image and I am getting
all sorts of errors...anyone have any ideas? I have searched the boards

and I keep getting the same error message each time I try to run the
macro...


===========================
Run-time error '91':
Object variable or With block variable not set


Sub SaveChartAsGIF ()
Fname = ThisWorkbook.Path & "\" & ActiveChart.Name & ".gif"
ActiveChart.Export FileName:=Fname, FilterName:="GIF"
End Sub
===========================
Run-time error '1004'
Method 'Export' of object '_Chart' failed


Dim mychart As Chart
Set mychart = ActiveSheet.ChartObjects(1).Chart
mychart.Export Filename:="c:\Mychart.gif", FilterName:="GIF"
============================


I have tried a few other codes on the boards and they all produce one
or the other errors shown above. It wouldn't be such a problem if I
could have a macro resize the CHART WINDOW to full screen but I can't
seem to find that information anywhere...Any help is much appreciated!
Thanks so much!



  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 6,953
Default Export Pie Graph Chart as Image

Both of your procedures worked fine for me.

The first one would require that a chart is selected.

The second one would require that the activesheet has a chartobject.

If you have a chartobject and you want to resize it in code, then use the
ActiveWindow.VisibleRange

Sub EFD()
Dim r As Range
Set r = ActiveWindow.VisibleRange
With ActiveSheet.ChartObjects(1)
.Top = r.Top
.Left = r.Left
.Width = r.Width
.Height = r.Height
End With
End Sub


--
Regards,
Tom Ogilvy


" wrote:

Hi,

I am trying to export a chart to a local *.gif image and I am getting
all sorts of errors...anyone have any ideas? I have searched the boards

and I keep getting the same error message each time I try to run the
macro...


===========================
Run-time error '91':
Object variable or With block variable not set


Sub SaveChartAsGIF ()
Fname = ThisWorkbook.Path & "\" & ActiveChart.Name & ".gif"
ActiveChart.Export FileName:=Fname, FilterName:="GIF"
End Sub
===========================
Run-time error '1004'
Method 'Export' of object '_Chart' failed


Dim mychart As Chart
Set mychart = ActiveSheet.ChartObjects(1).Chart
mychart.Export Filename:="c:\Mychart.gif", FilterName:="GIF"
============================


I have tried a few other codes on the boards and they all produce one
or the other errors shown above. It wouldn't be such a problem if I
could have a macro resize the CHART WINDOW to full screen but I can't
seem to find that information anywhere...Any help is much appreciated!
Thanks so much!


  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 6,953
Default Export Pie Graph Chart as Image

All this code worked for me:

Sub SaveChartAsGIF()
Fname = ThisWorkbook.Path & "\" & ActiveChart.Name & ".gif"
ActiveChart.Export Filename:=Fname, FilterName:="GIF"
End Sub

Sub ABC()
Dim mychart As Chart
Set mychart = ActiveSheet.ChartObjects(1).Chart
mychart.Export Filename:="c:\Mychart.gif", FilterName:="GIF"

End Sub
Sub EFD()
Dim r As Range
Set r = ActiveWindow.VisibleRange
With ActiveSheet.ChartObjects(1)
.Top = r.Top
.Left = r.Left
.Width = r.Width
.Height = r.Height
End With
End Sub

--
Regards,
Tom Ogilvy


" wrote:

Hi,

I am trying to export a chart to a local *.gif image and I am getting
all sorts of errors...anyone have any ideas? I have searched the boards

and I keep getting the same error message each time I try to run the
macro...


===========================
Run-time error '91':
Object variable or With block variable not set


Sub SaveChartAsGIF ()
Fname = ThisWorkbook.Path & "\" & ActiveChart.Name & ".gif"
ActiveChart.Export FileName:=Fname, FilterName:="GIF"
End Sub
===========================
Run-time error '1004'
Method 'Export' of object '_Chart' failed


Dim mychart As Chart
Set mychart = ActiveSheet.ChartObjects(1).Chart
mychart.Export Filename:="c:\Mychart.gif", FilterName:="GIF"
============================


I have tried a few other codes on the boards and they all produce one
or the other errors shown above. It wouldn't be such a problem if I
could have a macro resize the CHART WINDOW to full screen but I can't
seem to find that information anywhere...Any help is much appreciated!
Thanks so much!


  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 2,489
Default Export Pie Graph Chart as Image

Hi,

The error would suggest you do not have the graphics filters loaded.

If the Office install was not a complete install they may have been left
out. If I remember correctly they are in the Shared Tools section of
list of items to install.

Cheers
Andy

wrote:
Hi,

I am trying to export a chart to a local *.gif image and I am getting
all sorts of errors...anyone have any ideas? I have searched the boards

and I keep getting the same error message each time I try to run the
macro...


===========================
Run-time error '91':
Object variable or With block variable not set


Sub SaveChartAsGIF ()
Fname = ThisWorkbook.Path & "\" & ActiveChart.Name & ".gif"
ActiveChart.Export FileName:=Fname, FilterName:="GIF"
End Sub
===========================
Run-time error '1004'
Method 'Export' of object '_Chart' failed


Dim mychart As Chart
Set mychart = ActiveSheet.ChartObjects(1).Chart
mychart.Export Filename:="c:\Mychart.gif", FilterName:="GIF"
============================


I have tried a few other codes on the boards and they all produce one
or the other errors shown above. It wouldn't be such a problem if I
could have a macro resize the CHART WINDOW to full screen but I can't
seem to find that information anywhere...Any help is much appreciated!
Thanks so much!


--

Andy Pope, Microsoft MVP - Excel
http://www.andypope.info


  #6   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 6,953
Default Export Pie Graph Chart as Image

The error would suggest you do not have the graphics filters loaded.

I originally thought of suggesting that as well, but, while I wouldn't know
how to uninstall them to test, do you really think it would evoke a Run-time
error '91':
Object variable or With block variable not set?

That didn't seem to jive with me, but I have never not had them installed.

--
Regards,
Tom Ogilvy



"Andy Pope" wrote:

Hi,

The error would suggest you do not have the graphics filters loaded.

If the Office install was not a complete install they may have been left
out. If I remember correctly they are in the Shared Tools section of
list of items to install.

Cheers
Andy

wrote:
Hi,

I am trying to export a chart to a local *.gif image and I am getting
all sorts of errors...anyone have any ideas? I have searched the boards

and I keep getting the same error message each time I try to run the
macro...


===========================
Run-time error '91':
Object variable or With block variable not set


Sub SaveChartAsGIF ()
Fname = ThisWorkbook.Path & "\" & ActiveChart.Name & ".gif"
ActiveChart.Export FileName:=Fname, FilterName:="GIF"
End Sub
===========================
Run-time error '1004'
Method 'Export' of object '_Chart' failed


Dim mychart As Chart
Set mychart = ActiveSheet.ChartObjects(1).Chart
mychart.Export Filename:="c:\Mychart.gif", FilterName:="GIF"
============================


I have tried a few other codes on the boards and they all produce one
or the other errors shown above. It wouldn't be such a problem if I
could have a macro resize the CHART WINDOW to full screen but I can't
seem to find that information anywhere...Any help is much appreciated!
Thanks so much!


--

Andy Pope, Microsoft MVP - Excel
http://www.andypope.info

  #7   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 2,489
Default Export Pie Graph Chart as Image

Hi Tom,

No filters would not produce the 91 error. As you pointed out that's
more likely the chart not being active. A bad path also raises the 1004
error but the code would suggest that this is unlikely.

No chart active,
Error: 91 Object variable or With block variable not set

Incorrect Chartobject indexing,
Error: 1004 Unable to get the ChartObjects property of the Worksheet class

No graphic filter,
Error: 1004 Method 'Export' of object '_Chart' failed

Path does not exist,
Error: 1004 Method 'Export' of object '_Chart' failed

Cheers
Andy

Tom Ogilvy wrote:
The error would suggest you do not have the graphics filters loaded.



I originally thought of suggesting that as well, but, while I wouldn't know
how to uninstall them to test, do you really think it would evoke a Run-time
error '91':
Object variable or With block variable not set?

That didn't seem to jive with me, but I have never not had them installed.


--

Andy Pope, Microsoft MVP - Excel
http://www.andypope.info
  #8   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 6,953
Default Export Pie Graph Chart as Image

Andy,

Nice list. Thanks for responding. Upon reflection, I am guessing you used
a dummy format argument to test for no graphic filter (my bad <g).

--
Regards,
Tom Ogilvy


"Andy Pope" wrote:

Hi Tom,

No filters would not produce the 91 error. As you pointed out that's
more likely the chart not being active. A bad path also raises the 1004
error but the code would suggest that this is unlikely.

No chart active,
Error: 91 Object variable or With block variable not set

Incorrect Chartobject indexing,
Error: 1004 Unable to get the ChartObjects property of the Worksheet class

No graphic filter,
Error: 1004 Method 'Export' of object '_Chart' failed

Path does not exist,
Error: 1004 Method 'Export' of object '_Chart' failed

Cheers
Andy

Tom Ogilvy wrote:
The error would suggest you do not have the graphics filters loaded.



I originally thought of suggesting that as well, but, while I wouldn't know
how to uninstall them to test, do you really think it would evoke a Run-time
error '91':
Object variable or With block variable not set?

That didn't seem to jive with me, but I have never not had them installed.


--

Andy Pope, Microsoft MVP - Excel
http://www.andypope.info

Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Export Org chart as image Steve G[_3_] Charts and Charting in Excel 6 May 27th 08 09:05 AM
Image Export - Org Chart Steve G[_2_] Excel Worksheet Functions 1 May 22nd 08 08:48 PM
Export Pie Graph Chart as Image [email protected] Excel Discussion (Misc queries) 1 November 25th 06 06:57 PM
Export the worksheet background image as an image file - possible? DataFreakFromUtah Excel Programming 2 April 10th 04 04:49 PM


All times are GMT +1. The time now is 02:09 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Copyright ©2004-2025 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"