Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 8
Default Manipulating Charts with VBA

Hi All,

When I try to use the code below to change some chart properties I get various error like "
"Object doesn't support this method or property" (for the Refresh method) or the one which I can't
recall at this moment but basically says that the property can't be changed (regarding the
ChartTitle.Text property)

Sheet_6.ChartObjects(1).Visible = True
Sheet_6.ChartObjects(1).Chart.ChartTitle.Text = "Total Costs during Five Years of Analysis"
Sheet_6.ChartObjects(1).Refresh

Are these valid statements?

Rick
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 11
Default Manipulating Charts with VBA


"Rick" wrote in message
news:zhkgc.160673$K91.413926@attbi_s02...
Hi All,

When I try to use the code below to change some chart properties I get

various error like "
"Object doesn't support this method or property" (for the Refresh method)

or the one which I can't
recall at this moment but basically says that the property can't be

changed (regarding the
ChartTitle.Text property)

Sheet_6.ChartObjects(1).Visible = True
Sheet_6.ChartObjects(1).Chart.ChartTitle.Text = "Total Costs during Five

Years of Analysis"
Sheet_6.ChartObjects(1).Refresh



I am no expert, but from the Object Browser it appears that you are using
the wrong class for Chart.ChartTitle.Text


There are two classes listed, one singular and the other plural:
ChartObject
ChartObjects

The ChartTitle is a member of ChartObject, not ChartObjects


  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 126
Default Manipulating Charts with VBA

try DrawingObjects instead of ChartObjects, and see if that works.

Brian Murphy


"Colleyville Alan" wrote in message news:Z5lgc.16295$ru4.17030@attbi_s52...

"Rick" wrote in message
news:zhkgc.160673$K91.413926@attbi_s02...
Hi All,

When I try to use the code below to change some chart properties I get

various error like "
"Object doesn't support this method or property" (for the Refresh method)

or the one which I can't
recall at this moment but basically says that the property can't be

changed (regarding the
ChartTitle.Text property)

Sheet_6.ChartObjects(1).Visible = True
Sheet_6.ChartObjects(1).Chart.ChartTitle.Text = "Total Costs during Five

Years of Analysis"
Sheet_6.ChartObjects(1).Refresh



I am no expert, but from the Object Browser it appears that you are using
the wrong class for Chart.ChartTitle.Text


There are two classes listed, one singular and the other plural:
ChartObject
ChartObjects

The ChartTitle is a member of ChartObject, not ChartObjects


  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 27,285
Default Manipulating Charts with VBA

Sheet_6.ChartObjects(1).Chart.ChartTitle.Text = "Total Costs during Five
Years of Analysis"

give an error unless you make hascharttitle = true

With Sheet_6.ChartObjects(1).Chart
.HasTitle = True
.ChartTitle.Text = "Total Costs during Five Years of Analysis"
End With

there is no refresh method for a chartobject. The chart is refreshed when a
calculate is performed.

--
Regards,
Tom Ogilvy




"Rick" wrote in message
news:zhkgc.160673$K91.413926@attbi_s02...
Hi All,

When I try to use the code below to change some chart properties I get

various error like "
"Object doesn't support this method or property" (for the Refresh method)

or the one which I can't
recall at this moment but basically says that the property can't be

changed (regarding the
ChartTitle.Text property)

Sheet_6.ChartObjects(1).Visible = True
Sheet_6.ChartObjects(1).Chart.ChartTitle.Text = "Total Costs during Five

Years of Analysis"
Sheet_6.ChartObjects(1).Refresh

Are these valid statements?

Rick



  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 461
Default Manipulating Charts with VBA

Alan -

ChartObjects(1) refers to the first ChartObject in the collection.

Rick -

If the chart has no title, you will be unable to change its text. Use
this combination to add the title first:

With Sheet_6.ChartObjects(1).Chart
.HasChartTitle = True
.ChartTitle.Text = "Total Costs during Five Years of Analysis"
End With

You can't refresh a chartobject, just a chart:

Sheet_6.ChartObjects(1).Chart.Refresh

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

Colleyville Alan wrote:

"Rick" wrote in message
news:zhkgc.160673$K91.413926@attbi_s02...

Hi All,

When I try to use the code below to change some chart properties I get


various error like "

"Object doesn't support this method or property" (for the Refresh method)


or the one which I can't

recall at this moment but basically says that the property can't be


changed (regarding the

ChartTitle.Text property)

Sheet_6.ChartObjects(1).Visible = True
Sheet_6.ChartObjects(1).Chart.ChartTitle.Text = "Total Costs during Five


Years of Analysis"

Sheet_6.ChartObjects(1).Refresh




I am no expert, but from the Object Browser it appears that you are using
the wrong class for Chart.ChartTitle.Text


There are two classes listed, one singular and the other plural:
ChartObject
ChartObjects

The ChartTitle is a member of ChartObject, not ChartObjects





  #6   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 11
Default Manipulating Charts with VBA

"Jon Peltier" wrote in message
...
Alan -

ChartObjects(1) refers to the first ChartObject in the collection.


Thanks


  #7   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 8
Default Manipulating Charts with VBA

Jon Peltier wrote:

Alan -

ChartObjects(1) refers to the first ChartObject in the collection.

Rick -

If the chart has no title, you will be unable to change its text. Use
this combination to add the title first:

With Sheet_6.ChartObjects(1).Chart
.HasChartTitle = True
.ChartTitle.Text = "Total Costs during Five Years of Analysis"
End With

You can't refresh a chartobject, just a chart:

Sheet_6.ChartObjects(1).Chart.Refresh

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

Colleyville Alan wrote:

"Rick" wrote in message
news:zhkgc.160673$K91.413926@attbi_s02...

Hi All,

When I try to use the code below to change some chart properties I get



various error like "

"Object doesn't support this method or property" (for the Refresh
method)



or the one which I can't

recall at this moment but basically says that the property can't be



changed (regarding the

ChartTitle.Text property)

Sheet_6.ChartObjects(1).Visible = True
Sheet_6.ChartObjects(1).Chart.ChartTitle.Text = "Total Costs during
Five



Years of Analysis"

Sheet_6.ChartObjects(1).Refresh





I am no expert, but from the Object Browser it appears that you are using
the wrong class for Chart.ChartTitle.Text


There are two classes listed, one singular and the other plural:
ChartObject
ChartObjects

The ChartTitle is a member of ChartObject, not ChartObjects



Thanks everyone...and Jon you code works fine...thank you...
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
Manipulating DOS from VBA Dave Peterson[_3_] Excel Programming 0 October 17th 03 01:46 AM
manipulating pictures with VBA sec12205 Excel Programming 2 August 28th 03 04:36 PM
Manipulating Excel pie charts with VB Debra Dalgleish[_2_] Excel Programming 0 July 24th 03 01:08 AM
Manipulating Excel pie charts with VB Andrew[_16_] Excel Programming 0 July 24th 03 12:59 AM
Manipulating Excel pie charts with VB steve Excel Programming 0 July 23rd 03 07:02 PM


All times are GMT +1. The time now is 12:24 AM.

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

About Us

"It's about Microsoft Excel"