ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   FileExist doesn't work (https://www.excelbanter.com/excel-programming/294123-fileexist-doesnt-work.html)

Adrian[_4_]

FileExist doesn't work
 
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


Rob van Gelder[_4_]

FileExist doesn't work
 
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


--
Rob van Gelder - http://www.vangelder.co.nz/excel


"Adrian" wrote in message
...
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




Jean-Yves[_2_]

FileExist doesn't work
 
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




"Adrian" wrote in message
...
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





All times are GMT +1. The time now is 03:06 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com