Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.crashesgpfs,microsoft.public.excel.misc,microsoft.public.excel.programming
external usenet poster
 
Posts: 26
Default external data file locations

Windows XP, Office 2003

I use Access to build all my queries, and use 'get external data' to get the
data and build charts in Excel. As such, if I move the location of my Access
database, Excel gives me an error saying it cant find the file.

Does anyone know how I can move the Access database and then tell excel the
new location or something like that so it all still works?

Thanks,
Lou Sanderson
  #2   Report Post  
Posted to microsoft.public.excel.crashesgpfs,microsoft.public.excel.misc,microsoft.public.excel.programming
external usenet poster
 
Posts: 6,953
Default external data file locations

Edit the query - right click on the query and choose Edit=Query.

--
Regards,
Tom Ogilvy


"Lou Sanderson" wrote:

Windows XP, Office 2003

I use Access to build all my queries, and use 'get external data' to get the
data and build charts in Excel. As such, if I move the location of my Access
database, Excel gives me an error saying it cant find the file.

Does anyone know how I can move the Access database and then tell excel the
new location or something like that so it all still works?

Thanks,
Lou Sanderson

  #3   Report Post  
Posted to microsoft.public.excel.crashesgpfs,microsoft.public.excel.misc,microsoft.public.excel.programming
external usenet poster
 
Posts: 1,163
Default external data file locations

A quick way:
In VBA editor immediate pane, ?
Worksheets("SheetName").QueryTables(1).Connection shows the connection
string; for Access normally this will include in it the path to the Access
file. Use the Replace function to replace this with the new file path, e.g:
Worksheets("SheetName").QueryTables(1).Connection= Replace(Worksheets("SheetName").QueryTables(1).Con nection ,"C:\old path\file.mdb","C:\new path\file.mdb")

sorry about any word wrapping: the above should all be one long line
--
- K Dales


"Lou Sanderson" wrote:

Windows XP, Office 2003

I use Access to build all my queries, and use 'get external data' to get the
data and build charts in Excel. As such, if I move the location of my Access
database, Excel gives me an error saying it cant find the file.

Does anyone know how I can move the Access database and then tell excel the
new location or something like that so it all still works?

Thanks,
Lou Sanderson

  #4   Report Post  
Posted to microsoft.public.excel.crashesgpfs,microsoft.public.excel.misc,microsoft.public.excel.programming
external usenet poster
 
Posts: 718
Default external data file locations

You'll have to update Connection and CommandText attributes of the
querytable:

'------------
Sub ModQuery()
Const oldpath = "U:\Databases\mydatabase"
Const newpath = "C:\mydatabase"
Dim qt As QueryTable
Set qt = ActiveSheet.QueryTables(1)
With qt
.Connection = Replace(.Connection, oldpath, newpath)
.CommandText = Replace(.CommandText, oldpath, newpath)
End With
End Sub
'-----------

HTH
--
AP


"Lou Sanderson" a écrit dans le
message de ...
Windows XP, Office 2003

I use Access to build all my queries, and use 'get external data' to get

the
data and build charts in Excel. As such, if I move the location of my

Access
database, Excel gives me an error saying it cant find the file.

Does anyone know how I can move the Access database and then tell excel

the
new location or something like that so it all still works?

Thanks,
Lou Sanderson



  #5   Report Post  
Posted to microsoft.public.excel.crashesgpfs,microsoft.public.excel.misc,microsoft.public.excel.programming
external usenet poster
 
Posts: 26
Default external data file locations

K Dales,

OK, this changed the location of the "DBQ" (whatever that is) in the
connection string to the correct new location, but the "DefaultDir" remains
at the old location, and my error still exists....

Do I need to change the "DefaultDir" location as well, and if so can I have
help with that?

"K Dales" wrote:

A quick way:
In VBA editor immediate pane, ?
Worksheets("SheetName").QueryTables(1).Connection shows the connection
string; for Access normally this will include in it the path to the Access
file. Use the Replace function to replace this with the new file path, e.g:
Worksheets("SheetName").QueryTables(1).Connection= Replace(Worksheets("SheetName").QueryTables(1).Con nection ,"C:\old path\file.mdb","C:\new path\file.mdb")

sorry about any word wrapping: the above should all be one long line
--
- K Dales


"Lou Sanderson" wrote:

Windows XP, Office 2003

I use Access to build all my queries, and use 'get external data' to get the
data and build charts in Excel. As such, if I move the location of my Access
database, Excel gives me an error saying it cant find the file.

Does anyone know how I can move the Access database and then tell excel the
new location or something like that so it all still works?

Thanks,
Lou Sanderson

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
Using external data to connect to a .pst file Jackie Bauer Excel Discussion (Misc queries) 0 November 18th 06 11:12 PM
external data file locations Lou Sanderson Excel Discussion (Misc queries) 4 April 26th 06 05:17 PM
How do I reference external data from a file, file name found in . Clux Excel Discussion (Misc queries) 1 February 10th 05 10:52 PM
External File Data Import Adam Thickett Excel Programming 3 September 3rd 03 04:03 PM
Get External Data, Import Text File, File name problem Scott Riddle Excel Programming 1 July 11th 03 05:40 PM


All times are GMT +1. The time now is 06:56 PM.

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"