FileExist doesn't work

A

Adrian

Excel 2000, Windows 2000.
The code below fails at the second line "Object doesn't
support method"
(Both hu and student are strings with sensible values.)
I got the syntax from Excel's Help.
I've noticed that fileexist hasn't been turned into
FileExist, and though FileExist appears in the help index
it isn't found when I press F1...

If this method isn't available to me, can you suggest a
workaround?

Set fs = CreateObject("scripting.filesystemobject")
If fs.fileexist(hu & "\students\" & student & ".jpg") Then
' other stuff in here
End If
 
R

Rob van Gelder

You can do with without the Scripting library:

Sub test()
If Not Dir("C:\T\test.txt") = vbNullString Then
Debug.Print "other stuff in here"
End If
End Sub
 
J

Jean-Yves

Hi Adrian,

Ad an "s". => fso.FileExists( )
You can also use early binding to avoid syntax problems. Make a reference
to the Microsoft Scriptime Runtime library.

Dim fso as FileSystemObject
Set fso = new FileSystemObject
fso.(autocomplete will help you here)
......

Regards

Jean-Yves
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top