Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 2
Default ListObjects.Add error

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
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Counting instances of found text (Excel error? Or user error?) S Davis Excel Worksheet Functions 5 September 12th 06 04:52 PM
Error Handling - On Error GoTo doesn't trap error successfully David Excel Programming 9 February 16th 06 05:59 PM
listobjects and querytables S. Parker Excel Programming 0 November 14th 05 09:08 AM
Automation Error, Unknown Error. Error value - 440 Neo[_2_] Excel Programming 0 May 29th 04 05:26 AM


All times are GMT +1. The time now is 12:03 AM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Copyright ©2004-2025 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"