Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 34
Default How to delete QueryTable in VSTO?

How do I delete a QueryTable on an Excel spreadsheet using VB in VSTO?

In VBA, the following works, but I can't get anything to work in VB/VSTO.
ActiveSheet.Cells.Select
Selection.ListObject.QueryTable.Delete
--
Ed
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 118
Default How to delete QueryTable in VSTO?

Hello Ed,

I'm not sure that the following solution is related to this issue because
you did not tell the symptom in VSTO. If this solution is not helpful to
you, please let me know the error code in VSTO, and Office and VSTO
version. Thanks

--- SOLUTION ---
I know of a design change that we use Selection.ListObject.QueryTable in
Excel 2007 and Selection.QueryTable in the previous versions of Excel,
thus, you may need to detect the current office version
(Application.Version), and select Selection.ListObject.QueryTable or
Selection.QueryTable accordingly in the code.

Regards,
Jialiang Ge , 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/subscripti...ult.aspx#notif
ications.

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://msdn.microsoft.com/subscripti...t/default.aspx.
==================================================
This posting is provided "AS IS" with no warranties, and confers no rights.

  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 34
Default How to delete QueryTable in VSTO?

I had tried Selection.ListObject.QueryTable before--that was the code the VBA
macro recorder suggested, but it didn't work.

After considerable trial-and-error, I got the following to work from
ThisWorkbook:
Me.Sheets("Sheet1").ListObjects.Item(1).Delete()

or directly from Sheet1:
Me.ListObjects.Item(1).Delete()

As Excel is not zero-based, Item(1) would delete the one QueryTable on Sheet1.

The table I've been trying to delete is actually the new 'Table' in Excel
2007, which is apparently an updated version of a 'ListObject' in Excel 2003,
which may explain the difference in coding. It's confusing because when I
create the Table using the VBA macro recorder, the VBA code callis it a
QueryTable, and likewise with the macro recorder on, when I select and delete
the Table, the VBA again suggests it's a QueryTable. So there is some
inconsistency in the syntax between the VBA and VSTO, which explains my
difficulty in figuring out how to code it in VSTO.

--
Ed


""Jialiang Ge [MSFT]"" wrote:

Hello Ed,

I'm not sure that the following solution is related to this issue because
you did not tell the symptom in VSTO. If this solution is not helpful to
you, please let me know the error code in VSTO, and Office and VSTO
version. Thanks

--- SOLUTION ---
I know of a design change that we use Selection.ListObject.QueryTable in
Excel 2007 and Selection.QueryTable in the previous versions of Excel,
thus, you may need to detect the current office version
(Application.Version), and select Selection.ListObject.QueryTable or
Selection.QueryTable accordingly in the code.

Regards,
Jialiang Ge , 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/subscripti...ult.aspx#notif
ications.

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://msdn.microsoft.com/subscripti...t/default.aspx.
==================================================
This posting is provided "AS IS" with no warranties, and confers no rights.


  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 118
Default How to delete QueryTable in VSTO?

Hello Ed,

The day before yesterday, I submitted the issue in this post to the product
group. Today, I get their confirmation that they have logged this problem
into their database for fix. Thank you very much for your time and effort
to report this issue to us! If you have any other concerns, please DON'T
hesitate to tell me.

Thanks and have a very nice day!

Regards,
Jialiang Ge , 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:
.

This posting is provided "AS IS" with no warranties, and confers no rights.
=================================================

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
New QueryTable? Neily[_3_] Excel Programming 1 June 8th 07 01:28 PM
Run-time error "5" after range().delete runs before querytable.add [email protected] Excel Programming 5 September 7th 06 05:04 PM
web, querytable &jpg TomR Excel Programming 0 November 4th 05 04:30 PM
Bad QueryTable Row Count igneramos[_3_] Excel Programming 0 January 27th 04 10:21 PM
Querytable Ben.c Excel Programming 4 December 3rd 03 09:11 AM


All times are GMT +1. The time now is 10:13 PM.

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

About Us

"It's about Microsoft Excel"