is the file exists

A

a

Is possible to know (is the file exists)

Is possible to know (If folder exists)

What I want if the code find the file or folder (display message box (the
file exists) else (the file not exists)
 
D

Dale Fye

Check out the DIR function.

It allows you to pass the name (full path and name) of a file and if it
exists, returns just the name portion (without the path). If it doesn't
exist it returns an empty string.

It also accepts another parameter that allows you to check to see if a
directory exists.

HTH
Dale
 
A

a

Thank you for your help
can you write the code
i find short help about dir
The help not complete to write the code
 
A

AccessVandal via AccessMonster.com

Here's from Help.

Dir Function Example
This example uses the Dir function to check if certain files and directories
exist. On the Macintosh, “HD:†is the default drive name and portions of the
pathname are separated by colons instead of backslashes. Also, the Microsoft
Windows wildcard characters are treated as valid file-name characters on the
Mac. However, you can use the MacID function to specify file groups.

Dim MyFile, MyPath, MyName
' Returns "WIN.INI" (on Microsoft Windows) if it exists.
MyFile = Dir("C:\WINDOWS\WIN.INI")

' Returns filename with specified extension. If more than one *.ini
' file exists, the first file found is returned.
MyFile = Dir("C:\WINDOWS\*.INI")

' Call Dir again without arguments to return the next *.INI file in the
' same directory.
MyFile = Dir

' Return first *.TXT file with a set hidden attribute.
MyFile = Dir("*.TXT", vbHidden)

' Display the names in C:\ that represent directories.
MyPath = "c:\" ' Set the path.
MyName = Dir(MyPath, vbDirectory) ' Retrieve the first entry.
Do While MyName <> "" ' Start the loop.
' Ignore the current directory and the encompassing directory.
If MyName <> "." And MyName <> ".." Then
' Use bitwise comparison to make sure MyName is a directory.
If (GetAttr(MyPath & MyName) And vbDirectory) = vbDirectory Then
Debug.Print MyName ' Display entry only if it
End If ' it represents a directory.
End If
MyName = Dir ' Get next entry.
Loop

Also look here http://allenbrowne.com/ser-59.html
 

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