Update: Mit den Interop Assemblies funktioniert das auch nicht wie in VBA (scheint also kein NetOffice Problem zu sein). Folgender Code wirft die gleiche exception (ungültige Formel):
[TestMethod]
public void AddNameEnglish3()
{
Microsoft.Office.Interop.Excel.Application app = new Microsoft.Office.Interop.Excel.Application();
app.Visible = true;
app.Workbooks.Add();
app.ActiveWorkbook.Activate();
app.ActiveWorkbook.Names.Add("tester", "=Offset('Tabelle1'!$A$1,0,0,1,1)");
}
interessant ist, dass der folgende code einen Namen anlegt (";" anstatt "," in der Formel):[TestMethod]
public void AddNameEnglish4()
{
Microsoft.Office.Interop.Excel.Application app = new Microsoft.Office.Interop.Excel.Application();
app.Visible = true;
app.Workbooks.Add();
app.ActiveWorkbook.Activate();
app.ActiveWorkbook.Names.Add("tester", "=Offset('Tabelle1'!$A$1;0;0;1;1)");
}
Die angelegte Formel wird allerdings 1:1 übernommen, also als "=Offset(Tabelle1!$A$1;0;0;1;1)" hinterlegt. Aber meine deutsche Office Version kennt natürlich kein "Offset" und daher ist das unbrauchbar.