Query update not working in Workbook_Open() macro
Posted on 2016-11-25
I have a vba script that refreshes an Excel workbook tab with an external connection to a SQL database. The vba is part of a VBA script that calls separate scripts in an order. When I run the master VBA script manually, it completes without a problem.
However, when I copy the same VBA script to a private sub Workbook_Open() it gets a run time error 1004: Select Method of Worksheet Class Failed at the point of the query refresh.
Here is the vba script that throws the error:
' Update Meditech Data
Any ideas why it will not work when the workbook opens?