hi i am adding chart to excel from c# as follows
Excel.Worksheet ws =
(Excel.Worksheet) Globals.ThisAddIn.GetActiveWorksheet();
Excel.Shape chart =
(Excel.Shape) ws.Shapes.AddChart(Type.Missing,100,100,100,100);
is it possible now to add let’s say Rectangle on the chart above for example like
chart.Add(msoRectangle,100,100,100,100); // smth of this kind
so that when i drag the chart, chart objects (for example above rectangle) will move with the chart… and is it possible to make it uneditable? thanks a lot!
You have to get to the Chart.Shapes collection and add a new Rectangle Shape. There is not a lot of documentation on VSTO, so you just have to play around.
Now, about that read-only..I am not sure if you can protect just the chart, but you can of course protect the whole WorkSheet that the chart is on.
Here is how to password protect your sheet, this is a full protection.