How do I extract SQL code from MSQuery using VBA?

210 views Asked by At

Is there a way through VBA to be able to look for a querytable in a workbook and return the SQL code (as a string), as displayed within MSQuery?

I have to do this a fair bit and its a pain having to go into Edit Query, wait for it to load, press cancel, go to view in MS Query, wait some more, then finally hit the SQL button just to see a few lines of SQL code. Would be a lot easier if there was a non-GUI way of doing this.

The code shown does not necessarily need to be editable (so could be displayed in a msgbox), but if it could be changeable then that would be a nice bonus.

0

There are 0 answers