New to ExcelDNA and I'm converting/rewriting some old company macros into an addon and I cannot for the life of me figure out how to get ListObjects to work.
I created a new project and added a custom ribbon with a test button that calls:
using ExcelDna.Integration;
using Microsoft.Office.Interop.Excel;
public static void LoTest()
{
var xlApp = (Application)ExcelDnaUtil.Application;
xlApp.Workbooks.Add();
Worksheet sht = xlApp.Sheets.Add();
sht.Activate();
var src = new[] { "redacted connection string" };
ListObject lo = xlApp.ActiveSheet.ListObjects.Add(XlListObjectSourceType.xlSrcExternal, src, true, XlYesNoGuess.xlYes, xlApp.ActiveSheet.Range["A1"]);
}
The list objects.add call fails every time no matter what I do with:
System.ArgumentException: Value does not fall within the expected range.
Did I miss something super basic somewhere? The other things I've played with so far manipulating columns, cells, etc all seem to work fine. I can get it to create a query table from the same datasource as well, but I really need the listobject.