Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 21
Default Refreshing NON-embedded External Data Connections

Hey,

I have Excel 2007.
I have 3 external data connections in a workbook. 2 are embedded,1 is
NOT. I want to refresh the 3rd one that is NOT embedded in any
worksheet, but it wont let me. I've tried doing this on the GUI AND
through VBA, and cant get either method to work.

For instance when I click on the Data tab and then click on the
connections button, it brings up the Workbook Connections screen. If
I click on 1 of the 2 connections that are embedded, then I can click
the little Refresh drop down button and I have the option of clicking
"Refresh". However if I click on the connection that is NOT embedded,
I dont have that option.

Alternatively in VBA I used the following code:
Dim w As Worksheet, qt As QueryTable
Dim cn As WorkbookConnection
Dim odbcCn As ODBCConnection, oledbCn As OLEDBConnection
For Each cn In ThisWorkbook.Connections
cn.Refresh
Next

When I run it, each of the embedded queries refresh just fine, but
when it trys to execute the .Refresh command on the 3rd non-embedded
query, absolutely nothing happens. I dont get an error but the
connection also doesnt refresh.

Just for the heck of it, I tried to refresh it using a more direct
approach(which is really the same thing) using the following code:
ActiveWorkbook.Connections("CREATE TABLE
TBL_CR_Retail_Churn").Refresh

Again, it executes fine with no error, but it also doesnt refresh the
connection.

I dont care if I have to do this through the GUI or VBA, I just want
to be able to refresh non-embedded queries. its like Excel is somehow
actively rejecting the refresh command, eventhough it can clearly see
the connection and see's the .Refresh command as being valid for the
connection.

Any help will be very much appreciated.
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 236
Default Refreshing NON-embedded External Data Connections

It's the first time i've seen a construct like that where the
connection object is actually used as DDL statement (or the other way
around). But if it works - it's actually quite neat.
The way i see it Excel treats all the connection object as really
connection strings that pull data into the wb/ws and hence if there is
no target range for the data - there is nothing for it to refresh
(i.e., there is no range to populate with the updated data).
When you say:
"Again, it executes fine with no error, but it also doesnt refresh the
connection."
what exactly you expect to happen? How would you expect the 'refresh'
event to manifest itself?


On Mar 3, 6:35*pm, hutteto wrote:
Hey,

I have Excel 2007.
I have 3 external data connections in a workbook. *2 are embedded,1 is
NOT. *I want to refresh the 3rd one that is NOT embedded in any
worksheet, but it wont let me. *I've tried doing this on the GUI AND
through VBA, and cant get either method to work.

For instance when I click on the Data tab and then click on the
connections button, it brings up the Workbook Connections screen. *If
I click on 1 of the 2 connections that are embedded, then I can click
the little Refresh drop down button and I have the option of clicking
"Refresh". *However if I click on the connection that is NOT embedded,
I dont have that option.

Alternatively in VBA I used the following code:
* * * * Dim w As Worksheet, qt As QueryTable
* * * * Dim cn As WorkbookConnection
* * * * Dim odbcCn As ODBCConnection, oledbCn As OLEDBConnection
* * * * For Each cn In ThisWorkbook.Connections
* * * * * * cn.Refresh
* * * * Next

When I run it, each of the embedded queries refresh just fine, but
when it trys to execute the .Refresh command on the 3rd non-embedded
query, absolutely nothing happens. *I dont get an error but the
connection also doesnt refresh.

Just for the heck of it, I *tried to refresh it using a more direct
approach(which is really the same thing) using the following code:
* * * * ActiveWorkbook.Connections("CREATE TABLE
TBL_CR_Retail_Churn").Refresh

Again, it executes fine with no error, but it also doesnt refresh the
connection.

I dont care if I have to do this through the GUI or VBA, I just want
to be able to refresh non-embedded queries. *its like Excel is somehow
actively rejecting the refresh command, eventhough it can clearly see
the connection and see's the .Refresh command as being valid for the
connection.

Any help will be very much 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
External Data Connections Error Steph2010 Excel Discussion (Misc queries) 0 February 10th 10 05:25 AM
External data connections CellShocked Excel Worksheet Functions 2 October 25th 09 01:58 AM
Refreshing Workbook Connections with Access Jack PDX Excel Discussion (Misc queries) 0 March 26th 09 07:02 PM
How do I permanently remove external data connections? DOUBLEB Excel Worksheet Functions 0 January 9th 09 06:55 PM
Lost External Data Connections Jeff C Excel Discussion (Misc queries) 0 July 12th 07 10:14 PM


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