Results 1 to 5 of 5

Thread: Openning multiple text files

  1. #1

    Thread Starter
    Member
    Join Date
    Jan 2000
    Location
    Canada
    Posts
    34

    Talking

    Hi Everyone,

    I am trying to write a small EXE file so that it looks at a specific directory and opens all the available text files. The trick is that the name of these files are unknown and can be anything. However, the extention, as I said before, are all *.txt files.

    Could someone please shed some light on this?

    Thanks in advance,
    Regards

  2. #2
    Guest
    hi,
    I suggest you read up all about the FileSystemObject, which will let you perform a For Each...Next loop on the files in the directory, so you need never know the full filenames.

    mail me for a demo.

  3. #3
    Addicted Member
    Join Date
    May 2000
    Posts
    142
    yeah, do something like
    Code:
    ...
    for each objFile in collFiles
      if Mid$(objFile.Name,Len(objFile.Name)-3) = "txt" then
         'open the file here...
      end if
    next
    ...
    good luck
    /d*8/

  4. #4
    Fanatic Member
    Join Date
    Jan 2000
    Location
    Nitro
    Posts
    633
    Code:
    Option Explicit
    
    Private Declare Function ShellExecute Lib "shell32.dll" Alias "ShellExecuteA" (ByVal hwnd As Long, ByVal lpOperation As String, ByVal lpFile As String, ByVal lpParameters As String, ByVal lpDirectory As String, ByVal nShowCmd As Long) As Long
    
    Sub Main()
      'PURPOSE:List the Files in the selected directory
      ChDir "C:\Your Directory\"
      Dim strDir As String
      strDir = Dir("*.txt")
      
      Do Until strDir = ""
        Call ShellExecute(0, "Open", strDir, "", CurDir(), 1)
        strDir = Dir()
      Loop
    End Sub
    hmmmm.... How come the above code is spread out?

    Anyway, That is how to open all text files. If you want to open all *.doc, just change it in the codes. It will automatically open with its default opener which is Microsoft Word.

    Good Luck!

    [Edited by Nitro on 06-02-2000 at 12:22 PM]
    Chemically Formulated As:
    Dr. Nitro

  5. #5

    Thread Starter
    Member
    Join Date
    Jan 2000
    Location
    Canada
    Posts
    34

    Thumbs up

    Hello,

    Just wanted to thank you everyone for your quick replies.
    Regards

Posting Permissions

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



Click Here to Expand Forum to Full Width