Gerard75

Hi,

I setup my chart (embedded on a Worksheet, not a Chart Sheet) using one added at design time, using SetSourceData and so on.  However I may have to add the chart at runtime so that I can delete the chart because I was having issues.

The issue was I set the chart up in a specific way, setting the source data, max scales on the axes etc.  But when I try and change the max scale after the chart is set up (to accomodate new data) I get a "Unable to set the MaximumScale property of the Axis class" error.

Anyways, unless I can overcome this I was going to simply delete the chart and create a new one.  However using

(Excel.Chart)((Excel.ChartObjects)this.ChartObjects(missing)).Add(0, 0, 500, 500);

I get a ChartObject back, which I assume is the native object that say VBA would use.  I would like however to keep all my previous code (SetSourceData etc) and so was wondering is there a way to wrap this up inside the VSTO Chart object in Tools.Excel.Chart



Re: Visual Studio Tools for Office Can you wrap a ChartObject in a Tools.Excel.Chart ?

Gerard75

Sorry, I just realised that by deleting the axis ticklabels it was preventing me from setting its maximum value next time round. 

However, out of interest it would still be interesting to know if it was possible to wrap the object mentioned in the scenario above.

Thanks





Re: Visual Studio Tools for Office Can you wrap a ChartObject in a Tools.Excel.Chart ?

Mohit Gupta - MSFT

Hi Gerard.

You could use the dynamic controls in VSTO to create the chart and it will return a VSTO chart object instead of a native chart object. This feature exposes a number of AddXXX methods on the worksheet that allow you to add VSTO objects at runtime.

Hope this helps.