Stack overflow exception, when chart is selected

T

tiamat

Hi,

I am running Excel 2007 XP sp 3 and I have found you will get a stack
overflow exception if you:

1. Create a chart where the range is specified by SetDataSource
2. Select the chart so the chart and the series data are both selected
3. Make a request to retrieve a custom property for the worksheet
via :

Office.DocumentProperties props = null;

try
{
props = (Office.DocumentProperties)wb.CustomDocumentProperties;

if (props == null)
return matches;

// Check that the property does not already exist
for (int custom = 1; custom <= props.Count; custom++)
{
Office.DocumentProperty property = props[custom];
property = null;
}
}
....

The only workaround I have found so far is before I request the custom
property I reset the cell selection I.e.

Excel.Range rgCell = ws.get_Range("A$1$", "A$1$");
rgCell.Select();
rgCell = null;

This is a horrible hack - ideally I would like to 'Deselect' the chart and
its series data. However, using the Deselect method of Chart does not help as
the data is deselected but the chart still shows the selection border.

Can anyone provide any insight or help. Note I get a similar issue if I try
to write cell comments when a chart is selected.

If anything it would be useful to programmatically find what a charts series
range is and what the current selection range is and see if they intersect.
If so I can do the manual hack as above, if not, which is more pleasing then
do not attempt to reset.

Open to any suggestions.
Ta
 
T

tiamat

Found a viable solution - alot simpler than interrogating chart series
collection data which was one possible avenue.

// Check to see if we have an active chart
Excel.Chart ch = Application.ActiveChart;
if (ch == null)
return;
else
{
ch.Deselect();
ch = null;
}

// Force the selection to a cell
Excel.Range rgCell = ws.get_Range("A$1$", "A$1$");
rgCell.Select();
rgCell = null;
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top