This will do the job :-

Code:
'------------------------------
Sub test()
    Dim MyCount As Integer
    Dim MyName As String
    MyName = Dir("c:\*.doc")
    Do While MyName <> ""
        MyCount = MyCount + 1
        MyName = Dir
    Loop
    MsgBox (MyCount)
End Sub
'-------------------------------