Created
January 5, 2018 19:55
-
-
Save leblancfg/fd3f147475da5a20382c17d3844f338e to your computer and use it in GitHub Desktop.
Export all MS Access tables to UTF-8 CSVs
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
' This script will export all tables in its MS Access db to UTF-8 CSVs | |
' ----- | |
' The macro can then be run from the command line as: | |
' C:\path\to\Msaccess.exe "C:\path\to\database.accdb" /x "MACRO NAME" | |
Sub ExportTablesToCSV() | |
Const MyPath = "C:\ExportedTables\" | |
Dim db | |
Dim tdf | |
Dim objXl | |
Dim wbXL | |
Dim I As Long | |
Set db = CurrentDb | |
If Dir(MyPath, vbDirectory) = "" Then | |
MkDir MyPath | |
End If | |
For Each tdf In db.TableDefs | |
If Left(tdf.Name, 4) <> "MSys" And Left(tdf.Name, 1) <> "~" Then | |
DoCmd.TransferText acExportDelim, "", tdf.Name, MyPath & tdf.Name & ".csv", True, "", 65001 | |
End If | |
Next tdf | |
End Sub |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment