Last active
August 29, 2015 13:56
-
-
Save kbrammer/9235919 to your computer and use it in GitHub Desktop.
Export SQL Query Objects from Microsoft Access 2013
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
' http://msdn.microsoft.com/en-us/library/office/gg278834(v=office.15).aspx | |
Sub ExportQueryObjs() | |
' File System Properties | |
Const ForReading = 1, ForWriting = 2, ForAppending = 3 | |
Dim fs, f | |
Set fs = CreateObject("Scripting.FileSystemObject") | |
' DAO / Query definition properties | |
' http://stackoverflow.com/questions/20252599/how-do-you-export-ms-access-query-objects-to-text-file | |
Dim def As DAO.QueryDef | |
Dim defCol As DAO.QueryDefs | |
Set defCol = CurrentDb.QueryDefs | |
For Each def In defCol | |
Set f = fs.OpenTextFile("C:\" & def.Name & ".sql", ForWriting, TristateFalse) | |
f.Write def.SQL | |
f.Close | |
'Debug.Print def.Name & vbCrLf; | |
'Debug.Print def.SQL | |
Next | |
End Sub |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment