RoundRocket
New Member
- Joined
- Nov 28, 2013
- Messages
- 24
Hello,
I have a handy macro in excel 2007 which can perform a 'find and replace' on word documents depending on criteria placed on the excel worksheet. Currently, the macro is only searching through all docs in the initial folder it is navigated to search through and the first level of subfolders only, i'm wondering how i can get this to search through all subfolders of subfolders in the folder until it runs out of subfolders to search?? any help, suggestions you could give would be very much appreciated. Here is the snippet of code i currently have which relates to the subfolders search, i'm thinking i need to add in /amend some more code within here although i'm new to vba so unsure how to proceed on this... many thanks, Alex
' Call word replace again for each subfolder
Dim subFolder As folder, oFol As folder
Dim fso As New FileSystemObject
Dim strUCFolder As String
Set oFol = fso.GetFolder(searchPath)
For Each subFolder In oFol.SubFolders
strUCFolder = UCase(subFolder)
If InStr(strUCFolder, "REPLACEMENTS") = 0 And InStr(strUCFolder, "DOCUMENT MEDIA") Then
Call WordReplace(subFolder, subFolder)
End If
Next
Set oFol = Nothing
Set fso = Nothing
I have a handy macro in excel 2007 which can perform a 'find and replace' on word documents depending on criteria placed on the excel worksheet. Currently, the macro is only searching through all docs in the initial folder it is navigated to search through and the first level of subfolders only, i'm wondering how i can get this to search through all subfolders of subfolders in the folder until it runs out of subfolders to search?? any help, suggestions you could give would be very much appreciated. Here is the snippet of code i currently have which relates to the subfolders search, i'm thinking i need to add in /amend some more code within here although i'm new to vba so unsure how to proceed on this... many thanks, Alex
' Call word replace again for each subfolder
Dim subFolder As folder, oFol As folder
Dim fso As New FileSystemObject
Dim strUCFolder As String
Set oFol = fso.GetFolder(searchPath)
For Each subFolder In oFol.SubFolders
strUCFolder = UCase(subFolder)
If InStr(strUCFolder, "REPLACEMENTS") = 0 And InStr(strUCFolder, "DOCUMENT MEDIA") Then
Call WordReplace(subFolder, subFolder)
End If
Next
Set oFol = Nothing
Set fso = Nothing