I want to loop through a directory (using C#) and Refresh all Excel sheets in there. I use:
Workbook.RefreshAll();
How can I wait for the <
If you go through your Workbook
and set the the BackgroundQuery
property of all of your QueryTable
s to false
, RefreshAll
should finish before moving on.
foreach (Worksheet worksheet in workbook.Worksheets)
{
foreach (QueryTable table in worksheet.QueryTables)
table.BackgroundQuery = false;
}
//This will finish executing before moving on
workbook.RefreshAll();