Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default C# 2005 Excel access to Axis (xlSecondary)

hi,

i don't get access to the secondary axis by using the excel interop in
c#

at the following code i get an error "Exception from HRESULT:
0x800A03EC" (-2146827284)


//Add a Chart for the selected data.
oChart = (Excel.Chart)wb.Charts.Add(Missing.Value, Missing.Value,
Missing.Value, Missing.Value);

oChart.ChartType = XlChartType.xlColumnStacked;
oChart.set_HasAxis(Excel.XlAxisType.xlCategory,
Excel.XlAxisGroup.xlPrimary, true);
oChart.set_HasAxis(Excel.XlAxisType.xlValue,
Excel.XlAxisGroup.xlPrimary, true);
oChart.set_HasAxis(Excel.XlAxisType.xlCategory,
Excel.XlAxisGroup.xlSecondary, true);
oChart.set_HasAxis(Excel.XlAxisType.xlValue,
Excel.XlAxisGroup.xlSecondary, true);

Excel.Axis axCategory2 =
(Excel.Axis)oChart.Axes(Excel.XlAxisType.xlCategor y,
Excel.XlAxisGroup.xlSecondary);
axCategory2.CategoryType = XlCategoryType.xlAutomaticScale;
axCategory2.Border.Weight = 1;

Excel.Axis axCategory =
(Excel.Axis)oChart.Axes(Excel.XlAxisType.xlCategor y,
Excel.XlAxisGroup.xlPrimary);
axCategory.Border.LineStyle = Excel.XlLineStyle.xlDot;
axCategory.TickLabels.Orientation =
XlTickLabelOrientation.xlTickLabelOrientationHoriz ontal;
axCategory.TickLabels.Font.Size = 8;

oResizeRange = oWS.get_Range("B1:B" + anzDSReal.ToString(),
Missing.Value);
oChart.SetSourceData(oResizeRange, Excel.XlRowCol.xlColumns);
oChart.HasLegend = false;
....

can anyone help?

Thx
Thomas
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 6,582
Default C# 2005 Excel access to Axis (xlSecondary)

I can't say anything intelligent about the C# piece of your problem. For
plain old Excel/VBA I'd suggest checking that (a) you had two or more series
in the chart and that at least one series was in the xlSecondary AxisGroup,
and (b) the secondary axis doesn't coincide with a primary axis, because
sometimes if both axes are located along the same edge of the chart, one
(usually primary) prevents access to the other (usually secondary). The
position of an axis is set by the CrossesAt and CrossesAtMaximum properties
of the orthogonal axis (i.e., secondary value axis position controlled by
properties of secondary category axis), which also must exist.

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


wrote in message
...
hi,

i don't get access to the secondary axis by using the excel interop in
c#

at the following code i get an error "Exception from HRESULT:
0x800A03EC" (-2146827284)


//Add a Chart for the selected data.
oChart = (Excel.Chart)wb.Charts.Add(Missing.Value, Missing.Value,
Missing.Value, Missing.Value);

oChart.ChartType = XlChartType.xlColumnStacked;
oChart.set_HasAxis(Excel.XlAxisType.xlCategory,
Excel.XlAxisGroup.xlPrimary, true);
oChart.set_HasAxis(Excel.XlAxisType.xlValue,
Excel.XlAxisGroup.xlPrimary, true);
oChart.set_HasAxis(Excel.XlAxisType.xlCategory,
Excel.XlAxisGroup.xlSecondary, true);
oChart.set_HasAxis(Excel.XlAxisType.xlValue,
Excel.XlAxisGroup.xlSecondary, true);

Excel.Axis axCategory2 =
(Excel.Axis)oChart.Axes(Excel.XlAxisType.xlCategor y,
Excel.XlAxisGroup.xlSecondary);
axCategory2.CategoryType = XlCategoryType.xlAutomaticScale;
axCategory2.Border.Weight = 1;

Excel.Axis axCategory =
(Excel.Axis)oChart.Axes(Excel.XlAxisType.xlCategor y,
Excel.XlAxisGroup.xlPrimary);
axCategory.Border.LineStyle = Excel.XlLineStyle.xlDot;
axCategory.TickLabels.Orientation =
XlTickLabelOrientation.xlTickLabelOrientationHoriz ontal;
axCategory.TickLabels.Font.Size = 8;

oResizeRange = oWS.get_Range("B1:B" + anzDSReal.ToString(),
Missing.Value);
oChart.SetSourceData(oResizeRange, Excel.XlRowCol.xlColumns);
oChart.HasLegend = false;
...

can anyone help?

Thx
Thomas



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
Format date as Custom YYYY yields 2005, but fx still shows 1/1/2005 Captain Snuggles Excel Programming 2 October 27th 07 11:11 PM
I have a date 51231 (2005,dec,31) -I want to change to 2005/12/31 Curtis Excel Worksheet Functions 3 October 4th 06 11:38 PM
Convert alphanumerical(eg. 12.11.2005) to date as 12-Nov-2005 in e Safi Excel Discussion (Misc queries) 3 June 1st 06 04:35 PM
VBA Code to access the ACT! 2005 data bases and tables BAC Excel Programming 0 July 15th 05 06:25 PM
chnage date from tuesday 4 January 2005 10:39.26 to 04/01/2005 Jonny1975 Excel Worksheet Functions 1 June 6th 05 10:13 AM


All times are GMT +1. The time now is 11:24 PM.

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"