View Single Post
  #3   Report Post  
Posted to microsoft.public.excel.programming
Ed White Ed White is offline
external usenet poster
 
Posts: 34
Default Binding a DataSet to a ListObject

Such a simple solution! Yes, it works. Thanks
--
Ed


"""Ji Zhou [MSFT]""" wrote:

Hello Ed White,

We encounter the "Bad index" COM error because the base index of the
DataTable does not match the base index of the ListObject. The dot Net
collection object always takes 0 as its base index while the office
collection object uses 1. So, we just need to make a little modification,
changing the listTblCols(c) to listTblCols(c+1) in your codes. I have
tested with the following version which works fine.

Dim listTblCols As Excel.ListColumns = listTbl.ListColumns
For c = 0 To twsTable.Columns.Count - 1
listTblCols(c+1).Name = twsTable.Columns(c).ColumnName
Next c

Please have a try and let me know if it works for you. Have a good day!

Best regards,
Ji Zhou , remove 'online.')
Microsoft Online Community Support

Delighting our customers is our #1 priority. We welcome your comments and
suggestions about how we can improve the support we provide to you. Please
feel free to let my manager know what you think of the level of service
provided. You can send feedback directly to my manager at:
.

==================================================
Get notification to my posts through email? Please refer to
http://msdn.microsoft.com/en-us/subs...#notifications.

Note: The MSDN Managed Newsgroup support offering is for non-urgent issues
where an initial response from the community or a Microsoft Support
Engineer within 1 business day is acceptable. Please note that each follow
up response may take approximately 2 business days as the support
professional working with you may need further investigation to reach the
most efficient resolution. The offering is not appropriate for situations
that require urgent, real-time or phone-based interactions or complex
project analysis and dump analysis issues. Issues of this nature are best
handled working with a dedicated Microsoft Support Engineer by contacting
Microsoft Customer Support Services (CSS) at
http://support.microsoft.com/select/...tance&ln=en-us.
==================================================
This posting is provided "AS IS" with no warranties, and confers no rights.