The diagrams are stored in Shapes ;)
You need to go through the collection of shapes in worksheet and find a diagram by the name or by the index.
VBA code:
Function GetDiagramPosition(wsh As Worksheet, sName As String) As String
Dim shDgm As Shape, i As Integer
For i = 1 To wsh.Shapes.Count
Set shDgm = wsh.Shapes(i)
If shDgm.Name = sName Then Exit For
Next
GetDiagramPosition = shDgm.TopLeftCell.Address & ":" & shDgm.BottomRightCell.Address
End Function
C# code translated on:
http://www.carlosag.net/tools/codetranslator/[
^]
string GetDiagramPosition(Worksheet wsh, string sName) {
Shape shDgm;
for (int i = 1; (i <= wsh.Shapes.Count); i++) {
shDgm = wsh.Shapes(i);
if ((shDgm.Name == sName)) {
break;
}
}
return (shDgm.TopLeftCell.Address + (":" + shDgm.BottomRightCell.Address));
}
Result: "
$A$3:$H$7
"
To use the code above, you need to set reference to
Office.Interop.Excel[
^]