Resizing Existing charts in a sheet.

N

navin

Hi All,

I have a sheet, which has close to 20 charts, with different size
(height and width). I want to run a macro, which will make all the
charts in the sheets of same size (height and width). I tried defining
the chart object in the below code:



Sub test()
'
' test Macro
' Macro recorded 3/23/2007 by E366091
'
' Keyboard Shortcut: Ctrl+q
'
Dim ChtOb As ChartObjects


Set ChtOb = ActiveSheet.ChartObjects
For Each ChtOb in ChartObjects
ChtOb.Height=100
ChtOb.width=100

Next ChtOb
End Sub

Above code works properly, and sets ChtOb to ActiveSheet.ChartObjects
but when it comes to the next line it gives error as Object Required.

Please let me know as what is wrong with the code. Any suggestion is
appreciated.

Thanks,
Navin
 
J

Jim Cone

Sub test()
Dim ChtOb As ChartObject '(singular)

For Each ChtOb In ActiveSheet.ChartObjects
ChtOb.Height = 100
ChtOb.Width = 100
Next ChtOb

End Sub
--
Jim Cone
San Francisco, USA
http://www.realezsites.com/bus/primitivesoftware



"navin" <[email protected]>
wrote in message
Hi All,
I have a sheet, which has close to 20 charts, with different size
(height and width). I want to run a macro, which will make all the
charts in the sheets of same size (height and width). I tried defining
the chart object in the below code:

Sub test()
' test Macro
' Macro recorded 3/23/2007 by E366091
' Keyboard Shortcut: Ctrl+q
Dim ChtOb As ChartObjects
Set ChtOb = ActiveSheet.ChartObjects
For Each ChtOb in ChartObjects
ChtOb.Height=100
ChtOb.width=100
Next ChtOb
End Sub

Above code works properly, and sets ChtOb to ActiveSheet.ChartObjects
but when it comes to the next line it gives error as Object Required.
Please let me know as what is wrong with the code. Any suggestion is
appreciated.
Thanks,
Navin
 

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