Quantcast
Channel: NetOffice - MS Office in .NET
Viewing all articles
Browse latest Browse all 1741

New Post: Excel: Names.Add Method

$
0
0
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.

Viewing all articles
Browse latest Browse all 1741

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>