|
-
Jun 2nd, 2000, 01:45 AM
#1
Thread Starter
Member
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,
-
Jun 2nd, 2000, 01:49 AM
#2
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.
-
Jun 2nd, 2000, 02:06 AM
#3
Addicted Member
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/
-
Jun 2nd, 2000, 02:12 AM
#4
Fanatic Member
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
-
Jun 2nd, 2000, 03:15 AM
#5
Thread Starter
Member
Hello,
Just wanted to thank you everyone for your quick replies.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|