Refresh Workbook Connections

Glenn_Suggs

New Member
Joined
Aug 9, 2012
Messages
13
Hi all... I'm looking for a way to refresh all links in a workbook by looping thru a collection of "connections?" that exist without having to hard code each one. The RefreshAll method works ok but then stops everything if there's an error (bad/missing connection). I want to trap the error if one Refresh fails and then continue to the next one. The user wants the table (connection) name reported in a message box, but then needs the app to continue to the next connection and keep refreshing the data. (They could be Access, ODBC, or any)

Any ideas? Thanks in advance.

Glenn
 

Excel Facts

What did Pito Salas invent?
Pito Salas, working for Lotus, popularized what would become to be pivot tables. It was released as Lotus Improv in 1989.
Code:
Sub RefreshConns()
dim wbc as workbookconnection
on error resume next
for each wbc in thisworkbook.connections
wbc.refresh
if err.number <> 0 then
   msgbox wbc.name
   err.clear
end if
next wbc
end sub
 
Upvote 0
Code:
Sub RefreshConns()
dim wbc as workbookconnection
on error resume next
for each wbc in thisworkbook.connections
wbc.refresh
if err.number <> 0 then
   msgbox wbc.name
   err.clear
end if
next wbc
end sub

Thanks, RoryA... I'm gonna try that.
Glenn
 
Upvote 0

Forum statistics

Threads
1,223,228
Messages
6,170,871
Members
452,363
Latest member
merico17

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top