ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Macro to Refresh Data & Print (https://www.excelbanter.com/excel-programming/352097-macro-refresh-data-print.html)

cruwyser

Macro to Refresh Data & Print
 

Hi all,

I have a small problem.....I am currently using Excel to import some
external data from an Oracle database. As this is a report, the process
needs to be automated, hence I need a macro.

I need to generate a macro which refreshes the data in the worksheet,
then prints the report out and closes the workbook/applciation.

I have generated the macro, but the macro prints the report before the
data has refreshed.

Tried various versions of pause/wait/sleep, but still cant get it to
work?

Any ideas would be of great help!

Many thanks in advance.:)


--
cruwyser
------------------------------------------------------------------------
cruwyser's Profile: http://www.excelforum.com/member.php...o&userid=31064
View this thread: http://www.excelforum.com/showthread...hreadid=507369


JakeyC

Macro to Refresh Data & Print
 
By setting the BackgroundQuery property to False the code (and Excel)
will wait for the refresh to complete.

Range("Whatever").QueryTable.Refresh BackgroundQuery:=False should work



All times are GMT +1. The time now is 12:01 AM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
ExcelBanter.com