0

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.

Nimantha
  • 6,405
  • 6
  • 28
  • 69
bmgh1985
  • 779
  • 1
  • 14
  • 38
  • Have you tried recording a macro while going through this process? –  Nov 29 '13 at 11:04
  • Yeah, you dont get anything. I assume that Excel cannot record events happening in MSQuery – bmgh1985 Nov 29 '13 at 11:40
  • you're right. Read about modifying the MSQuery via VBA. You just need to find the right documentation –  Nov 29 '13 at 11:41

0 Answers0