Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
Home
DiscussionsAccessExcelInfoPathOutlookPowerPointPublisherWord
DirectoryUser Groups
Related Topics
Outlook ExpressInternet ExplorerWindowsMS Server ProductsMore Topics ...

MS Office Forum / Excel / Programming / May 2008

Tip: Looking for answers? Try searching our database.

C# 2005 Excel access to Axis (xlSecondary)

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
thomas.ziolko@web.de - 26 May 2008 14:56 GMT
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.xlCategory,
Excel.XlAxisGroup.xlSecondary);
axCategory2.CategoryType = XlCategoryType.xlAutomaticScale;
axCategory2.Border.Weight = 1;

Excel.Axis axCategory =
(Excel.Axis)oChart.Axes(Excel.XlAxisType.xlCategory,
Excel.XlAxisGroup.xlPrimary);
axCategory.Border.LineStyle = Excel.XlLineStyle.xlDot;
axCategory.TickLabels.Orientation =
XlTickLabelOrientation.xlTickLabelOrientationHorizontal;
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
Jon Peltier - 27 May 2008 21:10 GMT
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
_______

> hi,
>
[quoted text clipped - 42 lines]
> Thx
> Thomas
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.