![]() |
|
#1
|
||||
|
||||
![]()
With either set of code, modifications to allow a single prompt per folder are fairly simple. With mine, for example, to do that and process any first-page & even-page headers as well, change the UpdateDocumentHeaders sub to:
Code:
Sub UpdateDocumentHeaders() Application.ScreenUpdating = False Dim strFolder As String, strFile As String, wdDoc As Document Dim strFnd As String, strRep As String, wdStory(), i As Long strFolder = GetFolder If strFolder = "" Then Exit Sub strFnd = InputBox("Text to Replace", "Old String") strFile = Dir(strFolder & "\*.doc", vbNormal) strRep = InputBox("Replacement Text", "New String") wdStory = Array(wdPrimaryHeaderStory, wdFirstPageHeaderStory, wdEvenPagesHeaderStory) While strFile <> "" Set wdDoc = Documents.Open(FileName:=strFolder & "\" & strFile, AddToRecentFiles:=False, Visible:=False) With wdDoc On Error Resume Next For i = LBound(wdStory) To UBound(wdStory) MsgBox wdStory(i) With .StoryRanges(wdStory(i)).Find .ClearFormatting .Replacement.ClearFormatting .Text = strFnd .Replacement.Text = strRep .Forward = True .Wrap = wdFindContinue .Format = False .MatchCase = True .MatchWholeWord = True .MatchWildcards = False .MatchSoundsLike = False .MatchAllWordForms = False .Execute Replace:=wdReplaceAll End With Next On Error GoTo 0 .Close SaveChanges:=True End With strFile = Dir() Wend Set wdDoc = Nothing Application.ScreenUpdating = True End Sub
__________________
Cheers, Paul Edstein [Fmr MS MVP - Word] |
![]() |
|
![]() |
||||
Thread | Thread Starter | Forum | Replies | Last Post |
![]() |
AtaLoss | Word VBA | 37 | 09-22-2021 12:04 PM |
![]() |
redhin | Word VBA | 5 | 03-05-2013 05:42 AM |
![]() |
ubns | Word VBA | 7 | 08-16-2012 10:33 PM |
Multiple Headers in Same Worksheet | Tom | Excel | 3 | 05-18-2011 03:22 PM |
Multiple Headers | boutells | Word | 1 | 06-05-2009 12:04 AM |