Welcome to SPN

Register and Join the most happening forum of Sikh community & intellectuals from around the world.

Sign Up Now!

Importing Text Files

Discussion in 'Information Technology' started by Claude, Nov 2, 2005.

  1. Claude

    Claude
    Expand Collapse
    Guest

    I have a problem where I need to import a host of different text files from
    a directory where the file names are not consistently the same. I know how
    to do it no problem when I know the name but how do you do it when you
    don't know the name? Thanks in advance.

    Claude.
     
  2. Loading...

    Similar Threads Forum Date
    Malaysia Hindus, Sikhs In Malaysia Appalled With University Textbook Ridiculing Their Faiths Breaking News Jun 14, 2016
    Hard Talk Taking One Liners Out Of Context From Gurbani To Allow Intellectual Independence? Hard Talk Apr 23, 2016
    India Protests in India Over the Desecration of a Holy Text Leave Two Dead Breaking News Oct 16, 2015
    Learn Punjabi Convert Punjabi text Language, Arts & Culture Oct 11, 2013
    Sikh Coalition Harmeet Kaur Took the Lead ! First to Respond to Textbook Challenge ! Sikh Organisations May 25, 2013

  3. xRoachx

    xRoachx
    Expand Collapse
    Guest

    Here is a simple function that will loop through a specified directory
    looking for the specified file type. You may need to make adjustments
    depending on the type of text file you have (delimited or fixed) but this
    should get you started:

    Function fImportAllFiles()

    Dim strfile As String
    Dim strPath As String

    'File path to the Text files
    '
    strPath = "PATH TO YOUR FILES"

    'Change the default directory to the file path
    '
    ChDir strPath

    'Find the first Text file to use to create a string
    '
    strfile = Dir("*.txt")

    'Loop through the string & import
    '
    Do While Len(strfile) > 0

    DoCmd.TransferText acImportFixed, , "TABLE NAME"

    'delete the file (consider moving it to an Archive folder instead.)
    'Kill strPath & "/" & strfile

    'Call Dir to get the next file
    '
    strfile = Dir
    Loop

    End Function

    "Claude" wrote:

    > I have a problem where I need to import a host of different text files from
    > a directory where the file names are not consistently the same. I know how
    > to do it no problem when I know the name but how do you do it when you
    > don't know the name? Thanks in advance.
    >
    > Claude.
    >
     
  4. Claude

    Claude
    Expand Collapse
    Guest

    Thank you very much. It looks perfect! I'll let you know how it goes.

    Claude.
     
  5. Claude

    Claude
    Expand Collapse
    Guest

    Any idea why it always defaults to my My Documents directory? Otherwise its
    working perfect. Thanks again.

    Claude

    "=?Utf-8?B?eFJvYWNoeA==?=" <xRoachx@discussions.microsoft.com> wrote in
    news:8103DB14-2F9D-47DC-8268-DE7CF0F74DE3@microsoft.com:

    > Here is a simple function that will loop through a specified directory
    > looking for the specified file type. You may need to make adjustments
    > depending on the type of text file you have (delimited or fixed) but
    > this should get you started:
    >
    > Function fImportAllFiles()


    >>
     
  6. Claude

    Claude
    Expand Collapse
    Guest

    hehe never mind - stupid me. Figured it out. Thanks!
     

Share This Page