Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 265
Default problems changing the size of my chart

Hi, I have this code in a userform (in the Ok button):

Private Sub CommandButton1_Click()
ActiveChart.PageSetup.ChartSize = xlScreenSize
ActiveChart.ChartArea.Height = CLng(TextBox1)
ActiveChart.ChartArea.Width = CLng(TextBox2)
End
End Sub

when I select the chart and run the macro the following error occurs:

Run-time error '1004':

Unable to set the height property of the ChartArea class.

I have no Idea why is this happening; I chacked everithing and it still not
runing

Any suggestion

TIA
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 6,582
Default problems changing the size of my chart

You can only change the size and position of the ChartArea in a chart sheet,
not an embedded chart.

- Jon
-------
Jon Peltier, Microsoft Excel MVP
Tutorials and Custom Solutions
Peltier Technical Services, Inc. - http://PeltierTech.com
_______


"filo666" wrote in message
...
Hi, I have this code in a userform (in the Ok button):

Private Sub CommandButton1_Click()
ActiveChart.PageSetup.ChartSize = xlScreenSize
ActiveChart.ChartArea.Height = CLng(TextBox1)
ActiveChart.ChartArea.Width = CLng(TextBox2)
End
End Sub

when I select the chart and run the macro the following error occurs:

Run-time error '1004':

Unable to set the height property of the ChartArea class.

I have no Idea why is this happening; I chacked everithing and it still
not
runing

Any suggestion

TIA



  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 5,600
Default problems changing the size of my chart

ChartArea dimensions are read only. If you are dealing with an embedded
chart

ActiveChart.Parent.Width = newWidth

Note chartobject size is a tad larger than ChartArea size allowing for
border.

If(?) your intention is to change the size prior to printing (or viewable
size of a ChartSheet), change the margins under ActiveChart.PageSetUp, eg
..LeftMargin

Probabably better first to validate your textboxes contain valid dimentions.

NEVER use the End statement

Regards,
Peter T



"filo666" wrote in message
...
Hi, I have this code in a userform (in the Ok button):

Private Sub CommandButton1_Click()
ActiveChart.PageSetup.ChartSize = xlScreenSize
ActiveChart.ChartArea.Height = CLng(TextBox1)
ActiveChart.ChartArea.Width = CLng(TextBox2)
End
End Sub

when I select the chart and run the macro the following error occurs:

Run-time error '1004':

Unable to set the height property of the ChartArea class.

I have no Idea why is this happening; I chacked everithing and it still

not
runing

Any suggestion

TIA



  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 265
Default problems changing the size of my chart

what does embedded means??? It is hard to me to belive that it is not
possible to change the size of a chart, could you answer me if it is possible
and how, your answer was not clear.

thanks.

"Peter T" wrote:

ChartArea dimensions are read only. If you are dealing with an embedded
chart

ActiveChart.Parent.Width = newWidth

Note chartobject size is a tad larger than ChartArea size allowing for
border.

If(?) your intention is to change the size prior to printing (or viewable
size of a ChartSheet), change the margins under ActiveChart.PageSetUp, eg
..LeftMargin

Probabably better first to validate your textboxes contain valid dimentions.

NEVER use the End statement

Regards,
Peter T



"filo666" wrote in message
...
Hi, I have this code in a userform (in the Ok button):

Private Sub CommandButton1_Click()
ActiveChart.PageSetup.ChartSize = xlScreenSize
ActiveChart.ChartArea.Height = CLng(TextBox1)
ActiveChart.ChartArea.Width = CLng(TextBox2)
End
End Sub

when I select the chart and run the macro the following error occurs:

Run-time error '1004':

Unable to set the height property of the ChartArea class.

I have no Idea why is this happening; I chacked everithing and it still

not
runing

Any suggestion

TIA




  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 5,600
Default problems changing the size of my chart

An embedded chart is a chart on a sheet as distinct from a chart-sheet.
Typically embedded charts are on Worksheets though could also be embedded in
a chart-sheet.

A Chart-sheet type chart is not directly resizable, its dimensions are
determined by PageSetup properties, page size and margins, which you can
change.

An embedded chart's size can be changed by changing the size of its parent
container object - ChartObject.

If the above is not clear explain what you have, a chart-sheet or embedded
chart, and for what purpose do you want to change its size. Refer also to my
previous post.

Regards,
Peter T

"filo666" wrote in message
...
what does embedded means??? It is hard to me to belive that it is not
possible to change the size of a chart, could you answer me if it is

possible
and how, your answer was not clear.

thanks.

"Peter T" wrote:

ChartArea dimensions are read only. If you are dealing with an embedded
chart

ActiveChart.Parent.Width = newWidth

Note chartobject size is a tad larger than ChartArea size allowing for
border.

If(?) your intention is to change the size prior to printing (or

viewable
size of a ChartSheet), change the margins under ActiveChart.PageSetUp,

eg
..LeftMargin

Probabably better first to validate your textboxes contain valid

dimentions.

NEVER use the End statement

Regards,
Peter T



"filo666" wrote in message
...
Hi, I have this code in a userform (in the Ok button):

Private Sub CommandButton1_Click()
ActiveChart.PageSetup.ChartSize = xlScreenSize
ActiveChart.ChartArea.Height = CLng(TextBox1)
ActiveChart.ChartArea.Width = CLng(TextBox2)
End
End Sub

when I select the chart and run the macro the following error occurs:

Run-time error '1004':

Unable to set the height property of the ChartArea class.

I have no Idea why is this happening; I chacked everithing and it

still
not
runing

Any suggestion

TIA








  #6   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 265
Default problems changing the size of my chart

I defenetivly have a chart on a sheet because I have 4 different charts in
the same sheet and also the ploted data is in the same sheet.
how to programatically change the size???



"Peter T" wrote:

An embedded chart is a chart on a sheet as distinct from a chart-sheet.
Typically embedded charts are on Worksheets though could also be embedded in
a chart-sheet.

A Chart-sheet type chart is not directly resizable, its dimensions are
determined by PageSetup properties, page size and margins, which you can
change.

An embedded chart's size can be changed by changing the size of its parent
container object - ChartObject.

If the above is not clear explain what you have, a chart-sheet or embedded
chart, and for what purpose do you want to change its size. Refer also to my
previous post.

Regards,
Peter T

"filo666" wrote in message
...
what does embedded means??? It is hard to me to belive that it is not
possible to change the size of a chart, could you answer me if it is

possible
and how, your answer was not clear.

thanks.

"Peter T" wrote:

ChartArea dimensions are read only. If you are dealing with an embedded
chart

ActiveChart.Parent.Width = newWidth

Note chartobject size is a tad larger than ChartArea size allowing for
border.

If(?) your intention is to change the size prior to printing (or

viewable
size of a ChartSheet), change the margins under ActiveChart.PageSetUp,

eg
..LeftMargin

Probabably better first to validate your textboxes contain valid

dimentions.

NEVER use the End statement

Regards,
Peter T



"filo666" wrote in message
...
Hi, I have this code in a userform (in the Ok button):

Private Sub CommandButton1_Click()
ActiveChart.PageSetup.ChartSize = xlScreenSize
ActiveChart.ChartArea.Height = CLng(TextBox1)
ActiveChart.ChartArea.Width = CLng(TextBox2)
End
End Sub

when I select the chart and run the macro the following error occurs:

Run-time error '1004':

Unable to set the height property of the ChartArea class.

I have no Idea why is this happening; I chacked everithing and it

still
not
runing

Any suggestion

TIA






  #7   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 5,600
Default problems changing the size of my chart

I gave you the answer in my first post, change

ActiveChart.ChartArea.Width = CLng(TextBox2)

to
ActiveChart.Parent.Width = CLng(TextBox2.Text)

When the ActiveChart is an embedded chart its parent is a ChartObject, so
you could also do say

ActiveSheet.ChartObjects(1).Width = 200
or
ActiveSheet.ChartObjects("Chart 1").Height = 150

or you could even change all in one go

ActiveSheet.ChartObjects.Height = 100 ' assumes at least one chartobject

Regards,
Peter T



"filo666" wrote in message
...
I defenetivly have a chart on a sheet because I have 4 different charts in
the same sheet and also the ploted data is in the same sheet.
how to programatically change the size???



"Peter T" wrote:

An embedded chart is a chart on a sheet as distinct from a chart-sheet.
Typically embedded charts are on Worksheets though could also be

embedded in
a chart-sheet.

A Chart-sheet type chart is not directly resizable, its dimensions are
determined by PageSetup properties, page size and margins, which you can
change.

An embedded chart's size can be changed by changing the size of its

parent
container object - ChartObject.

If the above is not clear explain what you have, a chart-sheet or

embedded
chart, and for what purpose do you want to change its size. Refer also

to my
previous post.

Regards,
Peter T

"filo666" wrote in message
...
what does embedded means??? It is hard to me to belive that it is not
possible to change the size of a chart, could you answer me if it is

possible
and how, your answer was not clear.

thanks.

"Peter T" wrote:

ChartArea dimensions are read only. If you are dealing with an

embedded
chart

ActiveChart.Parent.Width = newWidth

Note chartobject size is a tad larger than ChartArea size allowing

for
border.

If(?) your intention is to change the size prior to printing (or

viewable
size of a ChartSheet), change the margins under

ActiveChart.PageSetUp,
eg
..LeftMargin

Probabably better first to validate your textboxes contain valid

dimentions.

NEVER use the End statement

Regards,
Peter T



"filo666" wrote in message
...
Hi, I have this code in a userform (in the Ok button):

Private Sub CommandButton1_Click()
ActiveChart.PageSetup.ChartSize = xlScreenSize
ActiveChart.ChartArea.Height = CLng(TextBox1)
ActiveChart.ChartArea.Width = CLng(TextBox2)
End
End Sub

when I select the chart and run the macro the following error

occurs:

Run-time error '1004':

Unable to set the height property of the ChartArea class.

I have no Idea why is this happening; I chacked everithing and it

still
not
runing

Any suggestion

TIA








  #8   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 265
Default problems changing the size of my chart

This worked perfectly:
Private Sub CommandButton1_Click()
On Error GoTo eh
ActiveChart.Parent.Width = CLng(TextBox1)
ActiveChart.Parent.Height = CLng(TextBox2)
eh:
End Sub

thanks for your help

"Peter T" wrote:

An embedded chart is a chart on a sheet as distinct from a chart-sheet.
Typically embedded charts are on Worksheets though could also be embedded in
a chart-sheet.

A Chart-sheet type chart is not directly resizable, its dimensions are
determined by PageSetup properties, page size and margins, which you can
change.

An embedded chart's size can be changed by changing the size of its parent
container object - ChartObject.

If the above is not clear explain what you have, a chart-sheet or embedded
chart, and for what purpose do you want to change its size. Refer also to my
previous post.

Regards,
Peter T

"filo666" wrote in message
...
what does embedded means??? It is hard to me to belive that it is not
possible to change the size of a chart, could you answer me if it is

possible
and how, your answer was not clear.

thanks.

"Peter T" wrote:

ChartArea dimensions are read only. If you are dealing with an embedded
chart

ActiveChart.Parent.Width = newWidth

Note chartobject size is a tad larger than ChartArea size allowing for
border.

If(?) your intention is to change the size prior to printing (or

viewable
size of a ChartSheet), change the margins under ActiveChart.PageSetUp,

eg
..LeftMargin

Probabably better first to validate your textboxes contain valid

dimentions.

NEVER use the End statement

Regards,
Peter T



"filo666" wrote in message
...
Hi, I have this code in a userform (in the Ok button):

Private Sub CommandButton1_Click()
ActiveChart.PageSetup.ChartSize = xlScreenSize
ActiveChart.ChartArea.Height = CLng(TextBox1)
ActiveChart.ChartArea.Width = CLng(TextBox2)
End
End Sub

when I select the chart and run the macro the following error occurs:

Run-time error '1004':

Unable to set the height property of the ChartArea class.

I have no Idea why is this happening; I chacked everithing and it

still
not
runing

Any suggestion

TIA






  #9   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 6,582
Default problems changing the size of my chart


A Chart-sheet type chart is not directly resizable, its dimensions are
determined by PageSetup properties, page size and margins, which you can
change.


That's what I was going to say, but I tried the OP's code and learned that
the chart area is resizable in a chart sheet. The code he posted works fine
for a chart sheet only.

- Jon
-------
Jon Peltier, Microsoft Excel MVP
Tutorials and Custom Solutions
Peltier Technical Services, Inc. - http://PeltierTech.com
_______



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
Chart Data Point Size Changing ? Bob[_19_] Charts and Charting in Excel 4 April 3rd 23 03:41 PM
Changing Chart Size with Excel 2007 Coop Research Excel Programming 0 June 20th 07 05:29 PM
Changing Chart Location Problems *Dave* Charts and Charting in Excel 1 February 11th 07 01:34 AM
Problems changing Embedded Chart Name [email protected] Excel Programming 0 October 13th 05 07:52 PM
Changing Excel Chart Size keepitcool Excel Programming 2 August 15th 03 03:25 PM


All times are GMT +1. The time now is 09:30 AM.

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"