-
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,
-
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.
-
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/
-
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]
-
Hello,
Just wanted to thank you everyone for your quick replies.