I have a protected workbook (which must stay protected) and on opening a macro runs to unprotect, it calls 2 queries does a few more things then re-protects the workbook. It seemed to be working at outset but doesn't now. I only realised it wasnt working when the data didnt seem right and looked at the show queries and it shows 'download did not complete'. Through the connections background refresh is not enabled, fast upload is ticked, also load to worksheet, not data model. One query pulls data from another unprotected workbook the other query pulls data from another worksheet within the same workbook
VBA is as follows
Pa few other routines run to copy and paste info around sheets, some on the back of the loaded queries thenPlease Login or Register to view this content.
It appears as though the macro is completing and re-protecting the workbook before the queries have completed retrieving their data/loading. Is there a way to ensure the queries complete their refresh before moving on to the next task? Does the background refresh need to somehow also need to be hardcoded into the VBA as well?Please Login or Register to view this content.
If I unprotect the workbook everything works fine
I have also tried putting the activeworkbook save after the connection refresh command
NB when I go into connections, where it says ThisWorkbook Data Model background query refresh is enabled there, but it is greyed out so I can't edit it, only the queries themselves
Bookmarks