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 <
The below code will work perfectly when your excel has to run background query to pull data from SQL Server/MS Access and it will wait for the query is successful.
public void RefreshSheet(Excel.Application Excel, Excel.Workbook WB)
{
WB.RefreshAll();
Excel.Application.CalculateUntilAsyncQueriesDone();
WB.save();
}
Here WB is the workbook and Excel is the Excel Application declared in your code.