Saving worksheet as CSV after pulling data from an external data source

R

Richard Edwards

All,

I am trying to load an Excel workbook. Have that workbook update from an
external datasource (oracle). Then save as a CSV.

I have tried putting code in the "on workbook open" but code is run before
the data is refreshed. The data is set to auto-refresh on startup

Does anyone have any suggestions?

Thank you.

Richard
 
B

Bernie Deitrick

Richard,

Use the Application.Ontime method to schedule an second macro (one that does
the worksheet export) a short time after the workbook opens, to give the
data pull time to finish.

HTH,
Bernie
MS Excel MVP
 
E

Earl Kiosterud

Richard,

Try this. Turn off Refresh on Open. In your code, do the refresh,
something like:

Range(OracleDataRange).QueryTable.Refresh BackgroundQuery:=False

Then save do the Save as CSV.
 
T

Tom Ogilvy

In the definition of your query table, don't allow it to do a background
refresh.
 
E

Earl Kiosterud

Tom,

I had to do a query refresh in code a while back, in Workbook_open, I'm
pretty sure. It was Excel 2000. The Refresh On Open didn't happen until
the Workbook_Open had run, so I did it in code.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top