#1   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 84
Default External Data Query

We've just moved our SQL databases and I have a spreadsheet that pulls in
external data from the old database. I've reset the ODBC links on my PC, but
the spreadsheet is still trying to look at the old server, so the link must
be somehow hard coded into the spreadsheet. I can't 'edit the query' from
the Data/Import External Data menu, so do you know how I can get into the
query to edit it? Thank you.
  #2   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 510
Default External Data Query

Bonjour Marie,

Take a look in VBA at the QueryTable Object which has Connection as a
property you can modify ...

HTH
Cheers
Carim

  #3   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 84
Default External Data Query

Thanks Carim, not sure where I'm looking for this, i've gone to View Code
from the tab, but can't find anything there (unless I'm looking in the wrong
place), do you have anymore suggestions? Thank you.

"Carim" wrote:

Bonjour Marie,

Take a look in VBA at the QueryTable Object which has Connection as a
property you can modify ...

HTH
Cheers
Carim


  #4   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 510
Default External Data Query

Marie,

You are right ... View Code and then the icon Object Browser ...

Meanwhile, found the following VBA code to ChangeServer

Sub ChangeServer()
'Declare your variables.
Dim ptc As PivotCache, oldSrv As String, newSrv As String

'Request the name of the old server/file name.
oldSrv = InputBox("Input the name of the old server or file path as

listed in the Pivot Tables SQL string.")

'Request the name of the new server/file name.
newSrv = InputBox("Input the name of the new server or file path
which
you want the Pivot Table to point to.")

'Replace the ODBC information of whatever PivotTable is currently
active.
Set ptc = ActiveCell.PivotTable.PivotCache
ptc.Connection = Application.Substitute(ptc.Connection, oldSrv,
newSrv)
ptc.Sql = Application.Substitute(ptc.Sql, oldSrv, newSrv)
End Sub


HTH
Cheers
Carim

  #5   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 84
Default External Data Query

Forgot to say thanks - Thanks!

"Carim" wrote:

Marie,

You are right ... View Code and then the icon Object Browser ...

Meanwhile, found the following VBA code to ChangeServer

Sub ChangeServer()
'Declare your variables.
Dim ptc As PivotCache, oldSrv As String, newSrv As String

'Request the name of the old server/file name.
oldSrv = InputBox("Input the name of the old server or file path as

listed in the Pivot Tables SQL string.")

'Request the name of the new server/file name.
newSrv = InputBox("Input the name of the new server or file path
which
you want the Pivot Table to point to.")

'Replace the ODBC information of whatever PivotTable is currently
active.
Set ptc = ActiveCell.PivotTable.PivotCache
ptc.Connection = Application.Substitute(ptc.Connection, oldSrv,
newSrv)
ptc.Sql = Application.Substitute(ptc.Sql, oldSrv, newSrv)
End Sub


HTH
Cheers
Carim


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
External data query leaves datasource workbook open WhytheQ Excel Discussion (Misc queries) 0 May 4th 06 03:54 PM
External data not updating [email protected] Excel Discussion (Misc queries) 0 March 16th 06 01:14 AM
AHHHH-Get Data from Multiple Excel workbooks JAA149 Excel Discussion (Misc queries) 5 October 30th 05 05:19 PM
External Data Andrew Hills Excel Discussion (Misc queries) 0 April 29th 05 02:38 AM
Prompting to allow External Query Data Refresh Tim Baker Excel Discussion (Misc queries) 3 March 8th 05 11:29 AM


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