Either you copy the entire procedure I gave you in the previous post and call it from the Click event:
Or you can rewrite the code into the Click eventCode:Private Sub Command1_Click() GetWordFiles("c:\TheFolderWhereTheWordFilesAre") End Sub
Good luck!Code:Private Sub Command1_Click() Dim fso As FileSystemObject Dim sFilename As String Dim fld As Folder Dim sPath As String 'Get the path! 'Either hardcode the path or ask the user for it! sPath = InputBox("Where are the Word files?") If Len(sPath) = 0 Then 'the User Clicked Cancel Exit Sub End If Set fso = New FileSystemObject If fso.FolderExists(sPath) Then sPath = sPath & IIf(Right$(sPath, 1) <> "\", "\", "") sFilename = Dir(sPath & "*.doc") Do While Len(sFilename) MsgBox sPath & sFilename sFilename = Dir Loop For Each fld In fso.GetFolder(sPath).SubFolders GetWordFiles fld.Path Next End If End Sub




Reply With Quote