Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming,microsoft.public.excel.misc,microsoft.public.excel.charting,microsoft.public.office.developer.automation
external usenet poster
 
Posts: 169
Default Update querytable connections and refresh data

I've cross posted this to several of the Excel and Office automation groups
in hopes of getting a quick response.

I've got an Excel spreadsheet that uses info from an Acccess database to
generate a series of charts. In the Excel spreadsheet, are a number of
querytables that are the data source for the charts.

Unfortunately, I'm having to carry these files around with me, and move them
to new locations on the network (or my USB drive) on a regular basis (don't
ask why). I'm trying to write a procedure to update the querytable
connection strings to point to the copy of the Access database which resides
in the same folder as the Excel workbook. I get the old path from the
connection, then determine the newpath based on the workbooks fullname, then
replace the oldpath with the newpath in the connection string. Most of that
process appears to be working.

qt.Connection = Replace( qt.connection, strOldPath, strNewPath)

But then I want to refresh the connection and refresh the data. I'm
currently using the following line, which is generating an error message.

qt.Refresh False

Run-time error '1004' General ODBC Error

If I don't put this line in the procedure, I get the proper connection
string when I type debug.print the connection in the Immediate window, but
when I put my cursor in one of the cells of the query table results, and
select 'Refresh Data' I get the following message:

[microsoft][odbc microsoft access driver] 'P:\...\...\filename.mdb' is not a
valid path. Make sure that the path name is spelled correctly and that you
are connected to the server on which the file resides.

and the filename that is listed in the message is the filename that was in
the old connection string, not the new one.

Ideas would be greatly appreciated.


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
Update querytable connections and refresh data Dale Fye Excel Discussion (Misc queries) 0 November 2nd 07 03:46 PM
Create refresh button in worksheet to refresh Pivot Table Data Ron Excel Worksheet Functions 1 October 13th 07 01:20 AM
Lost External Data Connections Jeff C Excel Discussion (Misc queries) 0 July 12th 07 10:14 PM
Security Issue: Data Connections Disabled Katara Excel Discussion (Misc queries) 0 March 8th 07 10:59 AM
Inability to start Excel after Refresh update kdixon7244 Excel Discussion (Misc queries) 1 September 29th 06 10:30 PM


All times are GMT +1. The time now is 10:37 AM.

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"