For instance non-activated office can cause such problem.
Reproduce steps:
- open vs code
- click right button on xlsx
- call Excel->M menu item
this results in handled error: .Queries field of activeX worksheet object is undefined.
When you close popup and follow the procedure again, it works.