Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default changing chart title via vba?

I don't understand why this is so difficult, but I'm trying to change
the title bar of a chart. I couldn't get the code to work, so I just
recorded a simple macro to see a "working" version. Problem is, the
recorded macro doesn't work either!

Here's the code from the macro:

Sub Macro1()
Sheets("3. FHS").Select
ActiveSheet.ChartObjects("ProjGraph1").Activate
ActiveChart.ChartTitle.Select
Selection.Characters.Text = "Text"
End Sub

When I press play from within the editor, I get:

Run-time error '-2147221080 (800401a8)':
Method'ChartTitle' of object'_Chart' failed

This should be so simple, but as a newbie, I'm making no progress
whatsoever ....

b



------------------------------------------------
~~ Message posted from http://www.ExcelTip.com/
~~ View and post usenet messages directly from http://www.ExcelForum.com/

  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 218
Default changing chart title via vba?

The following assumes that the chart is the first that was
added to the worksheet and therefore is referred to as
Chartobjects(1). Change the index number if necessary.
Note that there is no need to select anything.

Sub Macro1()
ActiveSheet.ChartObjects(1).Chart. _
ChartTitle.Characters.Text = "Text"
End Sub

-----Original Message-----
I don't understand why this is so difficult, but I'm

trying to change
the title bar of a chart. I couldn't get the code to

work, so I just
recorded a simple macro to see a "working" version.

Problem is, the
recorded macro doesn't work either!

Here's the code from the macro:

Sub Macro1()
Sheets("3. FHS").Select
ActiveSheet.ChartObjects("ProjGraph1").Activate
ActiveChart.ChartTitle.Select
Selection.Characters.Text = "Text"
End Sub

When I press play from within the editor, I get:

Run-time error '-2147221080 (800401a8)':
Method'ChartTitle' of object'_Chart' failed

This should be so simple, but as a newbie, I'm making no

progress
whatsoever ....

b



------------------------------------------------
~~ Message posted from http://www.ExcelTip.com/
~~ View and post usenet messages directly from

http://www.ExcelForum.com/

.

  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 27,285
Default changing chart title via vba?

Try it like this:

Sub Macro1()
With Sheets("3. FHS").ChartObjects("ProjGraph1")
.Chart.HasTitle = True
.Chart.ChartTitle.Text = "This is New Title"
End With
End Sub

--
Regards,
Tom Ogilvy

"basis" wrote in message
...
I don't understand why this is so difficult, but I'm trying to change
the title bar of a chart. I couldn't get the code to work, so I just
recorded a simple macro to see a "working" version. Problem is, the
recorded macro doesn't work either!

Here's the code from the macro:

Sub Macro1()
Sheets("3. FHS").Select
ActiveSheet.ChartObjects("ProjGraph1").Activate
ActiveChart.ChartTitle.Select
Selection.Characters.Text = "Text"
End Sub

When I press play from within the editor, I get:

Run-time error '-2147221080 (800401a8)':
Method'ChartTitle' of object'_Chart' failed

This should be so simple, but as a newbie, I'm making no progress
whatsoever ....

b



------------------------------------------------
~~ Message posted from http://www.ExcelTip.com/
~~ View and post usenet messages directly from http://www.ExcelForum.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
changing the title for a spreadsheet shown in IE mitchmcc Excel Discussion (Misc queries) 0 January 15th 10 01:46 AM
How to hide a chart title, but keep the title in the chart KBratt Charts and Charting in Excel 1 July 16th 09 12:13 AM
changing vbOKCancel button title Jase Excel Discussion (Misc queries) 8 August 19th 08 08:56 PM
Pasting Objects into Chart title and Axis title Sam Charts and Charting in Excel 1 June 6th 05 08:50 PM
Changing Graph Title W/ Pivot Jenn Excel Discussion (Misc queries) 1 January 19th 05 03:42 AM


All times are GMT +1. The time now is 12:11 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"