Home |
Search |
Today's Posts |
|
#1
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
I am trying to dynamically add a ListObject which references an external
SharePoint list to a worksheet in VSTO 2003. I am able to do this in VBA using the following code: Dim x(1) As Variant x(0) = "http://192.168.0.33/GPDS/_vti_bin" x(1) = "{1004279C-7047-448A-AD8B-B1A39ADCCFDE}" ws.ListObjects.Add xlSrcExternal, x, True, xlYes, ws.Range("A1") When I try to translate that to C# in VSTO 2003, I get an exception, "Bad variable type," using the following code: string [] myListSource = new string[3]; myListSource[0]="http://192.168.0.33/GPDS/_vti_bin"; myListSource[1]="{1004279C-7047-448A-AD8B-B1A39ADCCFDE}"; myListSource[2]="{3058AE3B-0603-4695-89E6-A949DF090D5D}"; Excel.Range rngTarget = ws.get_Range("A1",Type.Missing); ws.ListObjects.Add(Excel.XlListObjectSourceType.xl SrcExternal,myListSource,true,Excel.XlYesNoGuess.x lYes,rngTarget); The documentation for this method (http://msdn2.microsoft.com/en-us/lib...cts.add.asp x) states that I should be sending a string array of 3 elements...so I'm a little confused as to why the VBA code works, unless its variant data type behavior that allows it to work. Element 0 is the URL of the SharePoint site, element 1 is the GUID of the list, element 2 is the GUID of the view. Can anyone tell me where I've gone wrong? -- -Doug |
Reply |
Thread Tools | Search this Thread |
Display Modes | |
|
|
![]() |
||||
Thread | Forum | |||
Counting instances of found text (Excel error? Or user error?) | Excel Worksheet Functions | |||
Error Handling - On Error GoTo doesn't trap error successfully | Excel Programming | |||
listobjects and querytables | Excel Programming | |||
Automation Error, Unknown Error. Error value - 440 | Excel Programming |