Just a couple of things, you will need to change this line:
Dim fs, RAWFolder, File
To:
Dim fs, RAWFolder, File As Object
And you will have to change Interger to Integer.
This may seem a bit long winded after Hari's solution, but the following demonstrates a slightly different approach to iterating through all of the files in a Folder:
Private Sub Command1_Click()
Dim strDirPath As String
strDirPath = "C:\YourDirectoryName"
Dim lngFileCount As Long
lngFileCount = 0
If Right$(strDirPath, 1) <> "\" Then
strDirPath = strDirPath & "\"
End If
If GetAttr(strDirPath) = vbDirectory Then
strTempName = Dir(strDirPath, vbDirectory)
Do Until Len(strTempName) = 0
If (strTempName <> ".") And (strTempName <> "..") Then
If (GetAttr(strDirPath & strTempName) And vbDirectory) <> vbDirectory Then
lngFileCount = lngFileCount + 1
End If
End If
strTempName = Dir()
Loop
End If
Label1.Caption = lngFileCount
End Sub
Enter your message below
Sign in or Join us (it's free).