Export all tables to txt files with export specification
<p>I have a Access DB containing several different tables, each with a different structure (number &amp; names of fields, number of rows, title).</p>

<p>What I would like to do is to export all these tables into txt files, with a given separator ("|"), point as decimal separator, quotes for strings.</p>

<p>I have browsed the internet and what I got was:</p>

<ul>
<li>use <code>DoCmd.TransferText acExportDelim</code> command</li>
<li>save a customized export specification and apply it</li>
</ul>

<p>I get an error messagge ("object does not exist") and I think it is related to the fact that the export specification is "sheet-specific", i.e. does not apply to tables with different fields and fieldnames.</p>

<p>Can you help me?
thanks!!</p>

<p>EDIT.
I post also the original code I run. As I said before, I am new to VBA, so I just looked for a code on the web, adapted it to my needs, and run.</p>

<pre><code>Public Sub ExportDatabaseObjects()
On Error GoTo Err_ExportDatabaseObjects

Dim db As Database
Dim db As DAO.Database
Dim td As TableDef
Dim sExportLocation As String
Dim a As Long

Set db = CurrentDb()

sExportLocation = "C:\" 'Do not forget the closing back slash! ie: C:\Temp\

For a = 0 To db.TableDefs.Count - 1
    If Not (db.TableDefs(a).Name Like "MSys*") Then
        DoCmd.TransferText acExportDelim, "Export_specs",  db.TableDefs(a).Name, sExportLocation &amp; db.TableDefs(a).Name &amp; ".txt", True
    End If
Next a

Set db = Nothing

MsgBox "All database objects have been exported as a text file to " &amp; sExportLocation, vbInformation

Exit_ExportDatabaseObjects:
Exit Sub

Err_ExportDatabaseObjects:
MsgBox Err.Number &amp; " - " &amp; Err.Description
Resume Exit_ExportDatabaseObjects

End Sub
</code></pre>

<p>Before running the code, I manually exported the first table saving the Export_specs to a file.</p>

<p>Consider a db with two tables, A and B.
When I run the code A is properly exported, then I get the following errore message "3011 - The Microsoft Access database engine could not find the object 'B#txt'. Make sure the object exists and that you spell its name and the path name correctly. If 'B#txt' is not a local object, check your network connection or contact the server administration".</p>