#1
|
|||
|
|||
Folders within Folders within Folders!!!
Hello,
I have previously had marvelous help from here creating some vba code for an ongoing project I'm doing. It runs several jobs on Word documents in whatever folder I select. Sometimes, I have a job to do that has nested folders, and I have to run the vba code on each individual folder. This is a bit annoying, but it's rare enough that it hasn't been bad enough to ask for help. Now it is! I've had a job come in with 10 plus folders and each one of those folders has 1 or 2 or more sub folders, and each one of those has 4 subfolders! It's taking me forever to select all of those folders. Driving me batty. Is there a way to automatically run the vba code on all subfolders as well as the main folder I select? Here's the code I'm using now: Code:
Application.ScreenUpdating = False Dim strFolder As String, strFile As String, strDocNm As String, wdDoc As Document strDocNm = ActiveDocument.FullName strFolder = GetFolder If strFolder = "" Then Exit Sub strFile = Dir(strFolder & "\*.doc") While strFile <> "" Application.ScreenUpdating = False If strFolder & "\" & strFile <> strDocNm Then Set wdDoc = Documents.Open(FileName:=strFolder & "\" & strFile, AddToRecentFiles:=False, Visible:=False) With wdDoc With .Range.Find .ClearFormatting .Replacement.ClearFormatting .Forward = True .Wrap = wdFindContinue .Format = False .MatchCase = False .MatchWholeWord = False .MatchByte = True .MatchWildcards = True .MatchSoundsLike = False .MatchAllWordForms = False .Text = "Test Text 1" .Replacement.Text = "Replacement Text 2" .Execute Replace:=wdReplaceAll .Text = "Test Text 2" .Replacement.Text = "Replacement Text 2" .Execute Replace:=wdReplaceAll .Text = "Test Text 3" .Replacement.Text = "Replacement Text 3" .Execute Replace:=wdReplaceAll End With .Fields.Unlink .RemoveDocumentInformation (wdRDIAll) .Close SaveChanges:=True End With End If strFile = Dir() Wend Set wdDoc = Nothing Application.ScreenUpdating = True End Sub |
#2
|
||||
|
||||
__________________
Cheers, Paul Edstein [Fmr MS MVP - Word] |
#3
|
|||
|
|||
You are awesome!!!
Thank you A BILLION Times! |
Thread Tools | |
Display Modes | |
|
Similar Threads | ||||
Thread | Thread Starter | Forum | Replies | Last Post |
Moving Folders | iflog | Outlook | 2 | 06-17-2014 07:22 AM |
How to re-link default email acct folders to default Outlook Data File folders? | RDA1959 | Outlook | 0 | 03-26-2012 10:55 AM |
What happened to these folders | djclinton | Outlook | 2 | 05-24-2011 09:32 AM |
Where did my folders go? | WildBill | Outlook | 0 | 05-04-2011 08:57 AM |
Can Access access folders & sub-folders and dig out data? | nrg | Office | 4 | 06-20-2005 11:09 PM |