Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.charting
external usenet poster
 
Posts: 19
Default Setting chart title.

I am getting an ArgumentException with the message, "This object has no
title." from the following code:

chart.ChartTitle.Text = "Total Sales Comparison";

If I comment out this line the chart is created but the Title is "Chart
Title". What do I need to do to set the chart title?

If it helps here is the code I am using to create the chart:

Excel.Shape shape = ws.Shapes.AddChart(Excel.XlChartType.xlLine, missing,
missing, missing, missing);

shape.Name = "YTDTotalSales";

Excel.Chart chart = shape.Chart;

if (chart != null)
{
chart.SetSourceData(ws.get_Range(string.Format("{0 }2:{1}{2}",
(char)('A' + (baseColumn + 0)),
(char)('A' + (baseColumn + 4)), currentTotalList.Count + 2), missing),
missing);

((Excel.Axis)chart.Axes(Excel.XlAxisType.xlCategor y,Excel.XlAxisGroup.xlPrimary)).TickLabelPosition = Excel.XlTickLabelPosition.xlTickLabelPositionHigh;
chart.ChartTitle.Text = "Total Sales Comparison";
chart.ApplyLayout(3, missing);
}

Thank you.

Kevin


  #2   Report Post  
Posted to microsoft.public.excel.charting
external usenet poster
 
Posts: 2,489
Default Setting chart title.

Hi,

Try setting the charts HasTitle property to True before setting the text.

Cheers
Andy

--

Andy Pope, Microsoft MVP - Excel
http://www.andypope.info
"Kevin Burton" wrote in message
...
I am getting an ArgumentException with the message, "This object has no
title." from the following code:

chart.ChartTitle.Text = "Total Sales Comparison";

If I comment out this line the chart is created but the Title is "Chart
Title". What do I need to do to set the chart title?

If it helps here is the code I am using to create the chart:

Excel.Shape shape = ws.Shapes.AddChart(Excel.XlChartType.xlLine, missing,
missing, missing, missing);

shape.Name = "YTDTotalSales";

Excel.Chart chart = shape.Chart;

if (chart != null)
{
chart.SetSourceData(ws.get_Range(string.Format("{0 }2:{1}{2}",
(char)('A' + (baseColumn + 0)),
(char)('A' + (baseColumn + 4)), currentTotalList.Count + 2), missing),
missing);

((Excel.Axis)chart.Axes(Excel.XlAxisType.xlCategor y,Excel.XlAxisGroup.xlPrimary)).TickLabelPosition
= Excel.XlTickLabelPosition.xlTickLabelPositionHigh;
chart.ChartTitle.Text = "Total Sales Comparison";
chart.ApplyLayout(3, missing);
}

Thank you.

Kevin



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
Has anyone had problems setting the font size for a title through VBA? Viv2004 Charts and Charting in Excel 4 August 28th 05 12:23 PM
Excel chart - how to assign the file name in the chart title? TGreen Charts and Charting in Excel 1 August 16th 05 10:35 AM
Pasting Objects into Chart title and Axis title Sam Charts and Charting in Excel 1 June 6th 05 08:50 PM
SETTING AXIS TITLE matt a Charts and Charting in Excel 1 April 15th 05 03:50 PM
Chart Title LDanix Charts and Charting in Excel 2 January 17th 05 10:02 AM


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