Results 1 to 3 of 3
  1. #1
    Join Date
    Feb 2004

    Unanswered: Changing text file extensions

    In previous threads, I have seen references to a DOS shell and, possibly incorrectly, interpreted this to mean that there is a way to execute a DOS command (like a rename command) embedded in a routine. I import two different text files into two different in Access 2000 database, and the file extensions are not recognized by A2000. With the help of a kind person in a previous thread, I have two command buttons with on click routines as follows:

    Private Sub Import_Discrepancy_Files_Click()
    DoCmd.SetWarnings False

    Dim strTblName As String
    Dim StrImportSpec As String
    strTblName = "Pyxis Archive Data - Discrepancy"
    StrImportSpec = "Archive Import Specs, DTX"

    DoCmd.SetWarnings True

    Dim strImpPath As String
    Dim strImpFileNameExt As String
    strImpPath = "A:\"

    strImpFileNameExt = Dir(strImpPath & "*.TXT")
    While (strImpFileNameExt <> "")

    DoCmd.TransferText acImportDelim, StrImportSpec, strTblName, strImpPath & strImpFileNameExt, 1
    strImpFileNameExt = Dir
    End Sub

    The files are on floppy with several files of each type per disk. In order to import, I have to change the file extension in DOS command: Rename *.DTX *.TXT, before opening databse and clicking button. What I would like to do is change extension in the routine. One suggestion was to use OldName NewName code, but I can't seem to get it to work using wildcard. Would really appreciate any help I can get, as I am woefully inadequate in VB. Thanks for your time.

  2. #2
    Join Date
    Nov 2003
    - Do you want to change the file extenxtions from .DTX to .TXT?
    - What are the From/To file extensions?
    - Do you want to change the file extensions then after the routine is completed, change them back again?
    - Are the file names in Windows Long (Joliet) file name format?

  3. #3
    Join Date
    Feb 2004
    The file extension on the floppy is .DTX, and I would like to change it to .TXT, and, ideally, would like to change it back to .DTX after the import is done. From the naming I assume it is not Joilet, but really am a little vague on how to tell.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts