Results 1 to 4 of 4
  1. #1
    Sanchi Sharma is offline Novice
    Windows XP Access 2007
    Join Date
    Apr 2013
    Posts
    2

    Export All tables to txt file, filedseparator="|" , textqualifies=None,No Headings

    Hi All,

    I am new to Access Macros and to this forum.
    I want to export all the tables of Ms Access as txt file with fieldseparator ="|", textqualifies= none and with No Headings.
    I have created a Export Specification and as the heading of all the tables were different created query SELECT * FROM MSysIMEXColumns and deleted all the data from it. Because of which my Export Specification is working perfect but i am still getting the Headings in my text files.
    My Code:
    Public Sub Macro1()
    Dim td As DAO.TableDef, db As DAO.Database
    Dim out_file As String
    out_file = CurrentProject.Path & "\"
    Set db = CurrentDb()
    MsgBox "Txt file be saved at Database Path", vbOKOnly, ""
    For Each td In db.TableDefs
    If Left(td.Name, 4) <> "MSys" Then
    DoCmd.TransferText acExportDelim, "Sanchi2", td.Name, out_file & Replace(td.Name, "TblOut_", "") & "_Actual" & ".txt", False, ""
    End If
    Next


    End Sub

    Looking forward to all your inputs to help me with this. Thanks in advance

  2. #2
    Rawb is offline Expert
    Windows 7 64bit Access 2010 32bit
    Join Date
    Dec 2009
    Location
    Somewhere
    Posts
    875
    The only option I can think of (other than writing your own custom VBA Export functions) would be to make multiple Export specifications - one for each Table - and give them the same name as the Table. Then you can change your DoCmd.TransferText to the following:
    Code:
    DoCmd.TransferText acExportDelim, td.Name, td.Name, out_file &  Replace(td.Name, "TblOut_", "") & "_Actual" & ".txt", False, ""
    The problem there is that if you had 100 Tables, you'd need to make 100 Export Specifications :/

  3. #3
    Sanchi Sharma is offline Novice
    Windows XP Access 2007
    Join Date
    Apr 2013
    Posts
    2
    Thanxx Rawb.... have really liked your idea but yes it will be difficult if there are many tables..
    can you please tell me how to write the custom VBA export function....

  4. #4
    Rawb is offline Expert
    Windows 7 64bit Access 2010 32bit
    Join Date
    Dec 2009
    Location
    Somewhere
    Posts
    875
    Well, the short version is this: You'd open each file, one at a time. Then you'd read each file one line at a time, splitting it on the "|" character. Once you've read and split an entire line, you'd write the data to the appropriate Table (probably determined by the file name you're importing?).

    To get started, I'd take a look at the WSH ReadLine Method.

Please reply to this thread with any new information or opinions.

Similar Threads

  1. Replies: 4
    Last Post: 02-13-2013, 02:35 PM
  2. Access 2007 query export to Excel "feature"
    By sensetech in forum Import/Export Data
    Replies: 6
    Last Post: 11-03-2012, 04:24 AM
  3. Export "Query or Report" to a "Delimited Text File"
    By hawzmolly in forum Import/Export Data
    Replies: 3
    Last Post: 08-31-2012, 08:00 AM
  4. File Export "sort" issues
    By jgelpi16 in forum Programming
    Replies: 24
    Last Post: 09-15-2010, 12:14 PM
  5. Export to .rtf of "104-" converts to "-655&qu
    By Sherri726 in forum Import/Export Data
    Replies: 0
    Last Post: 12-19-2006, 03:16 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Other Forums: Microsoft Office Forums