|
-
May 17th, 2000, 06:29 PM
#1
Thread Starter
Fanatic Member
hi,
i'm creating a file using this code
Set fs = CreateObject("Scripting.FileSystemObject")
Set a = fs.CreateTextFile("C:\nax.txt", True)
a.writeline ("Part one completed, reg code will finally go here")
a.Close
and i want a want a way on form load that i can check to see if that file excists or not
thanks
Merlin ?
-
May 17th, 2000, 06:33 PM
#2
Addicted Member
Try opening it:
Set File= fs.GetFile("C:\nax.txt")
If len(file)=0 then
'File not found!!
end if
cheers,
André
-
May 17th, 2000, 06:45 PM
#3
Thread Starter
Fanatic Member
finding files
thanks andre
but now im getting the message
"Object not found "
Any Ideas
Merlin ?
-
May 17th, 2000, 07:02 PM
#4
Addicted Member
Is the error message "Object Required" ?
If yes, you probably did not Set the fs object in your form load, try this:
Private Sub Form_Load()
On Error Resume Next
Set fs = CreateObject("Scripting.FileSystemObject")
Set File = fs.GetFile("C:\nax.txt")
If Err.Number = 53 Then 'File not found
MsgBox "File Not Found"
End If
If Err.Number = 0 Then 'File found
MsgBox "File Found"
End If
End Sub
-
May 17th, 2000, 09:41 PM
#5
Thread Starter
Fanatic Member
Thanks a lot
hi,
thanks andre it works brilliantly now
i have got the program fully working now
Cheers again
Merlin ?
-
May 17th, 2000, 10:03 PM
#6
Fanatic Member
FileExists
An alternative method is the use the .FileExists function. This returns true if the file exists and false if it doesn't.
Code:
Set fs = CreateObject("Scripting.FileSystemObject")
If fs.FileExists("c:\nax.txt") then
'do whatever
Else
MsgBox "File Not Found"
End If
[Edited by Iain17 on 05-18-2000 at 04:05 PM]
Iain, thats with an i by the way!
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
|