Refreshing ListObject

mdmilner

Well-known Member
Joined
Apr 30, 2003
Messages
1,364
I've run into a curious problem.

Using Data-New Query - From Oracle Database, I've created an ODBC connection to oracle (with a SQL statement).
What I'd like to do is use VBA to force a refresh.

My current method is using SSIS to execute a "Macro"/subroutine which works until it gets an error.

The curious part is, if I manually use Data - Show Queries (and then close it), this code sample works.
When I do not manually (mouse and clicking) do this first, it fails.

Sheets("Data").Range("D8").Select
ActiveWorkbook.RefreshAll
Selection.ListObject.QueryTable.Refresh BackgroundQuery:=False

Using this below also fails until after the first time I've manually opened/closed the panel.
Application.CommandBars("Workbook Queries").Visible = True
Application.CommandBars("Workbook Queries").Visible = False

I'm sort of hoping there's something obvious and quick I'm just missing.

Mike
 
Last edited:

Excel Facts

How to fill five years of quarters?
Type 1Q-2023 in a cell. Grab the fill handle and drag down or right. After 4Q-2023, Excel will jump to 1Q-2024. Dash can be any character.

Forum statistics

Threads
1,224,823
Messages
6,181,181
Members
453,022
Latest member
Mohamed Magdi Tawfiq Emam

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