LinkBack Thread Tools Search this Thread Display Modes
Prev Previous Post   Next Post Next
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default Updating Excel QueryTable using VB

Hi,

I have searched the web extensively for a solution here but cannot find one.
I am using the following code to refresh data from an external data source in
excel.

With Selection.QueryTable.Connection = Array(Array( _
"ODBC;Description=Database;DRIVER=SQL
Server;SERVER=SERVER1\SQLEXPRESS;UID=username;APP= Microsoft Office
2003;WSID=HQD002;Netw" _
), Array("ork=DBNMPNTW;Trusted_Connection=Yes"))
.CommandType = xlCmdSql
.Sql = "SELECT * FROM vwDetailsReporting"
.PreserveColumnInfo = True
.Refresh BackgroundQuery:=False
End With

If I have deleted a couple of columns from the QueryTable and moved a few
columns around, then the above code updates the only columns in the Query
table that are still shown, which is as expected.

If I want to retreive some of the deleted columns then I can set the
..PreserveColumnInfo to False. This also works, and gives me all the columns
in the original query, but in the original order (overwriting the current
order of columns).

What I would like to do is be able recover the columns that I deleted
without reordering the existing columns. That is, just add the missing
columns to the end of the Querytable.

I can do this if I goto MS Query and then select File-Return Data to
Microsoft Office Excel. It gives me all the columns that I have previously
deleted at the end, but did not move any of the existing columns (ie.
preserved the existing column info). I would like to do this using code. Is
this possible?

Thanks

 
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
Excel AddNew QueryTable '1004' problem Holly[_3_] Excel Programming 1 November 7th 07 10:19 PM
Need HELP with QueryTable, ADO, EXCEL and EXCEL'S Formulas Javier Ortega Excel Programming 7 April 5th 05 06:47 PM
Excel Web Query using a QueryTable via HTTPS?? Bing Excel Programming 2 April 2nd 05 03:51 PM
Excel - VBA - QueryTable error 1004 Vuillermet Jacques Excel Programming 0 March 2nd 05 02:35 PM
ODBC / OLE DB QueryTable Editor Add-In for Excel Rob van Gelder[_4_] Excel Programming 0 December 18th 04 03:55 AM


All times are GMT +1. The time now is 07:11 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"