Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
IMT IMT is offline
external usenet poster
 
Posts: 2
Default Setting external data location for a pivot table

I want to create a spreadsheet that contaiins multiple pivot tables for a
single access database. As far as I see, Excel hardcodes the DSN information
for the ODBC connection. Thus if I give this speadsheet and access database
to someone else, they must put the access database in exactly the same
location (i.e. drive letter and subdirectory).

Normally, you would make a call for external data to the DSN which contains
the pointer to the location of the database. Thus you can move the database
anywhere you want as long as you relfect those changes in one single
location, the DSN. Excel seems t hardcode the DSN name as well as the path to
the database thus not allowing you to change it location.

As a work around I had a thought to create queries to use for each of the
pivot tables. I then tried creating the pivot tables based on a saved
queries. I figured then you can edit the individual query and change the
drive letters for all the info in the query (i.e. DSN, default location, etc)
since this all seems to be saved within the query. This would be labor
intensive but thought to be a workaround. However, when I saved the
spreadsheet with the pivot table. Disconnected the original mapped drive,
editited the query to reflect the new drive letter and tried to open up and
refresh the data, I got the error message telling me that it couldn't find
the ODBC datasource at the location of the original drive letter so it hard
coded again in there somewhere.

Anyone know of a workaround. Don't know if somethig could be done in VBA.
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 227
Default Setting external data location for a pivot table

Hi

This may help a little


Sub AmendPivotLocation()
Dim pt As PivotTable
Dim pc As PivotCache
Dim oldpath As String
Dim newpath As String
Dim ws As Worksheet
Dim wb As Workbook

Application.ScreenUpdating = False
Application.EnableEvents = False
On Error Resume Next

'Amend paths as necessary where Access database is stored
oldpath = "C:\MyFolder\FolderA\Work"
newpath = "C:\Work\Whatever"

Set wb = ThisWorkbook
For Each ws In wb.Worksheets
For Each pt In ws.PivotTables
pt.EnableWizard = True
Set pc = pt.PivotCache
pc.EnableRefresh = False
pc.Connection = Replace(pc.Connection, oldpath, newpath)
pc.EnableRefresh = True
pc.CommandText = Replace(pc.CommandText, oldpath, newpath)
Next pt
Next ws
Application.ScreenUpdating = True
Application.EnableEvents = True
End Sub

--

Regards

William

XL2003




"IMT" wrote in message
...
|I want to create a spreadsheet that contaiins multiple pivot tables for a
| single access database. As far as I see, Excel hardcodes the DSN
information
| for the ODBC connection. Thus if I give this speadsheet and access
database
| to someone else, they must put the access database in exactly the same
| location (i.e. drive letter and subdirectory).
|
| Normally, you would make a call for external data to the DSN which
contains
| the pointer to the location of the database. Thus you can move the
database
| anywhere you want as long as you relfect those changes in one single
| location, the DSN. Excel seems t hardcode the DSN name as well as the path
to
| the database thus not allowing you to change it location.
|
| As a work around I had a thought to create queries to use for each of the
| pivot tables. I then tried creating the pivot tables based on a saved
| queries. I figured then you can edit the individual query and change the
| drive letters for all the info in the query (i.e. DSN, default location,
etc)
| since this all seems to be saved within the query. This would be labor
| intensive but thought to be a workaround. However, when I saved the
| spreadsheet with the pivot table. Disconnected the original mapped drive,
| editited the query to reflect the new drive letter and tried to open up
and
| refresh the data, I got the error message telling me that it couldn't find
| the ODBC datasource at the location of the original drive letter so it
hard
| coded again in there somewhere.
|
| Anyone know of a workaround. Don't know if somethig could be done in VBA.


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
Pivot Table and External Data Charles Excel Worksheet Functions 0 December 3rd 09 09:33 AM
Pivot Table from External Data? geordie_phil Excel Discussion (Misc queries) 1 June 26th 08 11:13 AM
Pivot table accessing external data Jwaltb Excel Discussion (Misc queries) 6 February 22nd 07 06:04 PM
Determine the location of an external source of pivot table? Pivot Novice Excel Worksheet Functions 3 June 1st 05 09:34 PM
Pivot table using External data nc Excel Discussion (Misc queries) 3 April 26th 05 12:54 PM


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