View Single Post
  #3   Report Post  
Posted to microsoft.public.excel.programming
Tom Hutchins Tom Hutchins is offline
external usenet poster
 
Posts: 1,069
Default find out if its a folder or file

Maybe something like this:

Sub FilesAndFolders()
Dim myPath As String, myFile As String
myPath = "D:\Data\"
myFile = Dir(myPath, vbDirectory)
Do While myFile < ""
If myFile < "." And myFile < ".." Then
If (GetAttr(myPath & myFile) And vbDirectory) < 0 Then
MsgBox "Folder: " & myPath & myFile
Else
MsgBox "File: " & myPath & myFile
End If
End If
myFile = Dir()
Loop
End Sub

Hope this helps,

Hutch

"Rivers" wrote:

hi guys i need help a little help

myfile contains a folder path or a file i need a way to determine which one
it is i tried the instr below but found that files with a "." in missed my
loop totally so this doesnot suit my needs is this possible to do?

myFile = Dir(myPath, vbDirectory)
Do While myFile < "" 'will start LOOP until all files in folder
If InStr(myFile, ".") 0 Then