VBA to export multiple tables to .txt files

dreid1011

Well-known Member
Joined
Jun 4, 2015
Messages
3,638
Office Version
  1. 365
Platform
  1. Windows
Good morning,

I have a macro that I converted to VB so I can export multiple tables to individual .txt files.

Here's what I have:

Code:
Function Quarterly_Export_Macro()
On Error GoTo Quarterly_Export_Macro_Err
    Dim strName() As Variant
    Dim i As Integer
    strName = Array("MS_ACCOUNT", "[COLOR="#FF0000"][/COLOR][B]MS_EXEMPTIONS[/B]", "MS_FLOORS", "MS_INVENTORY", "MS_NOTATIONS", "MS_SPECIAL_ASSESSMENT", "MS_VALUE_SUMMARY", "ORCATS_NAMES", "P_ACCOUNT", "P_VALUES", "R_FLOOR_INV", "R_IMPR_ACC", "R_SPECIAL_ASSESSMENT", "REAL_ACCOUNT", "REAL_DEAD_NUMBERS", "REAL_EXEMPTIONS", "REAL_IMPROVEMENTS", "REAL_LAND_ADJUSTMENTS", "REAL_LAND_SIZES", "REAL_LAST_SALE", "REAL_LEGAL", "REAL_MAP_XREF", "REAL_NOTATIONS", "REAL_SALES", "REAL_SALES_ACCOUNTS", "REAL_SITUS", "REAL_VALUE_SUMMARY", "REAL_VALUES", "TAX_TOTALS", "TAXES_DELINQUENT", "tblFIELD_DESCRIPTIONS", "U_ACCOUNT", "U_VALUES")
    
    For i = 0 To 33
    DoCmd.TransferText acExportDelim, "QExportSpecs", strName(i), "F:\Quarterly Exports\" & strName(i) & ".txt", True
    Next
    
Quarterly_Export_Macro_Exit:
    Exit Function

Quarterly_Export_Macro_Err:
    MsgBox Error$
    Resume Quarterly_Export_Macro_Exit

End Function

I've set up an array for all the table names, and that seems to work fine. It gets through the first table, and then I receive an error stating that my second table(bold entry above) does not exist, but it's not the correct name in the error.

TCe2ey7

Imgur

Any help is much appreciated, thanks!
 
Ok, it's working great! I just need to redo some of the specs, I missed a number I think.
 
Upvote 0

Excel Facts

Show numbers in thousands?
Use a custom number format of #,##0,K. Each comma after the final 0 will divide the displayed number by another thousand
Alright! It works like a charm. Thank you for helping me in the right direction.
 
Upvote 0
Excellent! You are welcome.
 
Upvote 0

Forum statistics

Threads
1,226,171
Messages
6,189,395
Members
453,543
Latest member
rzavalamol777

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top