I have a issue where the VBA code for Workbook queries do not work until I interactively only the Workbook Query. I know it sounds weird.

I have the following code that makes the Workbook Queries (Data > Show Queries) Panel visible. If I open the workbook and try this run this, I will get a run-time error.

Application.CommandBars("Workbook Queries").Visible = True

The error is:
run-time error '5': Invalid procedure call or argument.

Once I click the Data > Show Queries the VBA code will work successfully now. If I close Excel and reload that workbook, I have to do the same thing. VBA refreshing the Workbook Queries will be successfully only after clicking on Show Queries at least one time.

Anything seen this issue?