Note: The other languages of the website are Google-translated. Back to English
Oturum aç  \/ 
x
or
x
Kaydol  \/ 
x

or

Birden çok dosyada kelimede nasıl arama yapılır ve değiştirilir?

Aynı içeriği (üstbilgi, altbilgi, bazı özel sözcükler veya sayılar gibi) içeren birkaç düzine sözcük dosyanız varsa ve bu belgelerde aynı içeriği Word'de değiştirmeniz gerekir. Hızlı bir şekilde halletmeniz sizin için ne kadar kolay olurdu? Kesinlikle, aynı içeriği değiştirmek için bu dosyaları tek tek açabilirsiniz, ancak bu zaman alıcı ve zahmetli olacaktır. Bu eğitim, size aynı içeriği Word'deki birden çok belgede aynı anda değiştirmenin zor bir yolunu gösterecektir.

VBA kodu ile aynı anda birden çok kelime belgesinde metinleri bulun ve değiştirin
Kutools for Word ile aynı anda birden fazla belgede farklı metinleri kolayca bulun ve değiştirin


VBA kodu ile aynı anda birden çok kelime belgesinde metinleri bulun ve değiştirin

1. Basın Ara Toplam + F11 açmak için Uygulamalar için Microsoft Visual Basic pencere.

2. içinde Uygulamalar için Microsoft Visual Basic Pencere, tıklayın Eklemodül, ardından aşağıdaki VBA kodunu Modül penceresine kopyalayın.

VBA Kodu: Bir seferde birden çok belgede aynı içeriği arama ve değiştirme

Sub CommandButton1_Click()
'Updated by Extendoffice 20180625
Dim xFileDialog As FileDialog, GetStr(1 To 100) As String '100 files is the maximum applying this code
Dim xFindStr As String
Dim xReplaceStr As String
Dim xDoc As Document
On Error Resume Next
Set xFileDialog = Application.FileDialog(msoFileDialogFilePicker)
With xFileDialog
    .Filters.Clear
    .Filters.Add "All WORD File ", "*.docx", 1
    .AllowMultiSelect = True
    i = 1
    If .Show = -1 Then
        For Each stiSelectedItem In .SelectedItems
            GetStr(i) = stiSelectedItem
            i = i + 1
        Next
        i = i - 1
    End If
    Application.ScreenUpdating = False
    xFindStr = InputBox("Find what:", "Kutools for Word", xFindStr)
    xReplaceStr = InputBox("Replace with:", "Kutools for Word", xReplaceStr)
    For j = 1 To i Step 1
        Set xDoc = Documents.Open(FileName:=GetStr(j), Visible:=True)
        Windows(GetStr(j)).Activate
        Selection.Find.ClearFormatting
        Selection.Find.Replacement.ClearFormatting
        With Selection.Find
            .Text = xFindStr  'Find What
            .Replacement.Text = xReplaceStr  'Replace With
            .Forward = True
            .Wrap = wdFindAsk
            .Format = False
            .MatchCase = False
            .MatchWholeWord = False
            .MatchByte = True
            .MatchWildcards = False
            .MatchSoundsLike = False
            .MatchAllWordForms = False
        End With
        Selection.Find.Execute Replace:=wdReplaceAll
        Application.Run macroname:="NEWMACROS"
        ActiveDocument.Save
        ActiveWindow.Close
    Next
    Application.ScreenUpdating = True
End With
MsgBox "Operation end, please view", vbInformation
End Sub

3. Tuşuna basın. F5 kodu çalıştırmak için anahtar.

4. Açılışta Araştır penceresi, lütfen içinde bulacağınız ve değiştireceğiniz belgeleri bulup seçin ve ardından OK buton. Ekran görüntüsüne bakın:

5. İlkinde Kutools for Word iletişim kutusunda, belgeler arasında bulacağınız metni Ne bul ve ardından OK düğmesine basın.

6. saniyede Kutools for Word iletişim kutusunda, değiştireceğiniz metni girin ve OK düğmesine basın.

8. Tıklayın OK sonraki düğme Microsoft Word Bul ve değiştir işlemini bitirmek için iletişim kutusu.

Bu durumda, seçilen belgelerdeki tüm "Word" sözcükleri aynı anda "Excel" ile değiştirilir.


Kutools for Word ile aynı anda birden fazla belgede farklı metinleri kolayca bulun ve değiştirin

İşte kesinlikle tavsiye ederim Toplu Bul ve Değiştir özelliği Kutools for Word. Bu özellikle, farklı metinleri birden çok Word belgesinde aynı anda kolayca bulabilir ve değiştirebilirsiniz. Belgeler arasında metin bulmak ve değiştirmek için bu özelliği nasıl uygulayacağımızı görelim.

Kutools for Word : 100'den fazla kullanışlı Word eklentisiyle, 60 gün içinde hiçbir sınırlama olmaksızın ücretsiz denemek.

1. Lütfen tıklayın Kutools Plus > Toplu Bul ve Değiştir özelliği etkinleştirmek için.

2. içinde Toplu Bul ve Değiştir iletişim kutusu, lütfen aşağıdaki gibi yapılandırın.

  • 2.1) satır ekle düğmesi altında Bul ve Değiştir sekme;
  • 2.2) Oluşturulan satır alanlarında:
A. Bulacağınız metni aşağıdaki metin kutusuna girin. bulmak sütun
B. Değiştireceğiniz metni metin kutusuna girin. değiştirmek sütun;
C. Bir arama türü, metnin nerede bulunacağını ve metni istediğiniz gibi vurgulamak için bir renk belirtin. Bu durumda seçiyorum Tam kelime eşleme, Ana belge ve belli bir renk Arama Tipi, Bulmak ve Vurgulamak sütun;
  • 2.3) Bulacağınız ve değiştireceğiniz daha fazla metin eklemek için 2.1 ve 2.2 adımlarını tekrarlayın;
  • 2.4)  düğmesi Dosya tipi metinleri bulup değiştireceğiniz Word belgelerini eklemek için bölüm;
  • 2.5) değiştirmek or bulmak buton. Ekran görüntüsüne bakın:

notlar:
1. Tıklarsanız bulmak düğmesinin altında tüm bulgu sonuçları görüntülenecektir. Sonucu Önizle sekmesi. Sonuçların önizlemesini yaptıktan sonra, tüm metinleri değiştirmek isterseniz, lütfen Bul ve Değiştir sekmesi. Aksi takdirde, iletişim kutusunu kapatın.

2. Tıklarsanız değiştirmek düğmesi, belirtilen tüm metinler hemen yenileriyle değiştirilecek ve sonuçlar ayrıca Sonucu Önizle sekmesi.

3. 2. adımda vurgu renkleri belirtirseniz, değiştirilen tüm metinler belirtilen renklerle vurgulanır ve bunları belgelerde bir bakışta kolayca bulabilirsiniz.

3. Kapat Toplu Bul ve Değiştir iletişim kutusu

Bu özellik hakkında daha fazla bilgi için lütfen buraya tıklayın ....

Bu yardımcı programı ücretsiz olarak denemek istiyorsanız, lütfen şu adrese gidin: yazılımı ücretsiz indirin önce ve sonra yukarıdaki adımlara göre işlemi uygulamaya gidin.



Önerilen Word Üretkenlik Araçları

 

Kutools For Word - Word İçin 100'den Fazla Gelişmiş Özellik,% 50 Zaman Kazanın

  • Karmaşık ve tekrarlanan işlemler saniyeler içinde tek seferlik işlem yapılabilir.
  • Klasörler arasında birden çok görüntüyü aynı anda Word belgesine ekleyin.
  • Birden çok Word dosyasını klasörler arasında istediğiniz sırada birleştirin ve birleştirin.
  • Geçerli belgeyi başlık, bölüm sonu veya diğer kriterlere göre ayrı belgelere bölün.
  • Dosyaları Doc ve Docx, Docx ve PDF, ortak dönüştürme ve seçim için araçlar koleksiyonu vb. Arasında dönüştürün ...

Say something here...
symbols left.
You are guest
or post as a guest, but your post won't be published automatically.
Loading comment... The comment will be refreshed after 00:00.
  • To post as a guest, your comment is unpublished.
    T-H · 3 months ago
    This is SUCH a time saving solution. THANK YOU!
    One thing that may make it even better, is adding support for subdirectories. (That is: Files in multiple subdirectories)
    I am an absolute newbie in this, and don't know the syntax, the parameter, or where to add that.

    Could somebody help?
  • To post as a guest, your comment is unpublished.
    crystal · 10 months ago
    @Daphne Hi Daphne,
    Why not try the Batch Find and Replace feature of Kutools for Word? It can solve this issue with ease.
  • To post as a guest, your comment is unpublished.
    Michael · 10 months ago
    @crystal Oh yeah! Thank you sooooo much! This is a life-saver!
  • To post as a guest, your comment is unpublished.
    Daphne · 1 years ago
    I need to replace text in multiple Word files and have the replaced text highlighted. Is there a way to do this?
  • To post as a guest, your comment is unpublished.
    Justine Belle · 1 years ago
    this was a lifesaver thank you so much
  • To post as a guest, your comment is unpublished.
    crystal · 2 years ago
    @nathalie Hi,
    Please apply the below VBA code to include the content of headers and footers when finding and replacing texts in multiple documents at once.

    Sub CommandButton1_Click()
    'Updated by Extendoffice 20180625
    Dim xFileDialog As FileDialog, GetStr(1 To 100) As String '100 files is the maximum applying this code
    Dim xFindStr As String
    Dim xReplaceStr As String
    Dim xDoc As Document
    On Error Resume Next
    Set xFileDialog = Application.FileDialog(msoFileDialogFilePicker)
    With xFileDialog
    .Filters.Clear
    .Filters.Add "All WORD File ", "*.docx", 1
    .AllowMultiSelect = True
    i = 1
    If .Show = -1 Then
    For Each stiSelectedItem In .SelectedItems
    GetStr(i) = stiSelectedItem
    i = i + 1
    Next
    i = i - 1
    End If
    Application.ScreenUpdating = False
    xFindStr = InputBox("Find what:", "Kutools for Word", xFindStr)
    xReplaceStr = InputBox("Replace with:", "Kutools for Word", xReplaceStr)
    For j = 1 To i Step 1
    Set xDoc = Documents.Open(FileName:=GetStr(j), Visible:=True)
    Windows(GetStr(j)).Activate
    Selection.Find.ClearFormatting
    Selection.Find.Replacement.ClearFormatting
    With Selection.Find
    .Text = xFindStr 'Find What
    .Replacement.Text = xReplaceStr 'Replace With
    .Forward = True
    .Wrap = wdFindAsk
    .Format = False
    .MatchCase = False
    .MatchWholeWord = False
    .MatchByte = True
    .MatchWildcards = False
    .MatchSoundsLike = False
    .MatchAllWordForms = False
    End With
    Selection.Find.Execute Replace:=wdReplaceAll
    Application.Run macroname:="NEWMACROS"
    If MsgBox("Do you want to replace texts in headers and footers too? ", vbYesNo, "Kutools for Word") = vbYes Then
    ActiveWindow.View.SplitSpecial = wdPanePrimaryFooter
    Selection.Find.Execute Replace:=wdReplaceAll
    Application.Run macroname:="NEWMACROS"
    ActiveWindow.View.SplitSpecial = wdPanePrimaryHeader
    Selection.Find.Execute Replace:=wdReplaceAll
    Application.Run macroname:="NEWMACROS"
    End If
    ActiveDocument.Save
    ActiveWindow.Close
    Next
    Application.ScreenUpdating = True
    End With
    MsgBox "Operation end, please view", vbInformation
    End Sub
  • To post as a guest, your comment is unpublished.
    crystal · 2 years ago
    @zofito Hi Tiago,
    Please apply the below VBA code to include the content of headers and footers when finding and replacing texts in multiple documents at once.

    Sub CommandButton1_Click()
    'Updated by Extendoffice 20180625
    Dim xFileDialog As FileDialog, GetStr(1 To 100) As String '100 files is the maximum applying this code
    Dim xFindStr As String
    Dim xReplaceStr As String
    Dim xDoc As Document
    On Error Resume Next
    Set xFileDialog = Application.FileDialog(msoFileDialogFilePicker)
    With xFileDialog
    .Filters.Clear
    .Filters.Add "All WORD File ", "*.docx", 1
    .AllowMultiSelect = True
    i = 1
    If .Show = -1 Then
    For Each stiSelectedItem In .SelectedItems
    GetStr(i) = stiSelectedItem
    i = i + 1
    Next
    i = i - 1
    End If
    Application.ScreenUpdating = False
    xFindStr = InputBox("Find what:", "Kutools for Word", xFindStr)
    xReplaceStr = InputBox("Replace with:", "Kutools for Word", xReplaceStr)
    For j = 1 To i Step 1
    Set xDoc = Documents.Open(FileName:=GetStr(j), Visible:=True)
    Windows(GetStr(j)).Activate
    Selection.Find.ClearFormatting
    Selection.Find.Replacement.ClearFormatting
    With Selection.Find
    .Text = xFindStr 'Find What
    .Replacement.Text = xReplaceStr 'Replace With
    .Forward = True
    .Wrap = wdFindAsk
    .Format = False
    .MatchCase = False
    .MatchWholeWord = False
    .MatchByte = True
    .MatchWildcards = False
    .MatchSoundsLike = False
    .MatchAllWordForms = False
    End With
    Selection.Find.Execute Replace:=wdReplaceAll
    Application.Run macroname:="NEWMACROS"
    If MsgBox("Do you want to replace texts in headers and footers too? ", vbYesNo, "Kutools for Word") = vbYes Then
    ActiveWindow.View.SplitSpecial = wdPanePrimaryFooter
    Selection.Find.Execute Replace:=wdReplaceAll
    Application.Run macroname:="NEWMACROS"
    ActiveWindow.View.SplitSpecial = wdPanePrimaryHeader
    Selection.Find.Execute Replace:=wdReplaceAll
    Application.Run macroname:="NEWMACROS"
    End If
    ActiveDocument.Save
    ActiveWindow.Close
    Next
    Application.ScreenUpdating = True
    End With
    MsgBox "Operation end, please view", vbInformation
    End Sub
  • To post as a guest, your comment is unpublished.
    zofito · 2 years ago
    Is it possible to replace in the headers of the word doc?
  • To post as a guest, your comment is unpublished.
    dsadasd · 2 years ago
    Is that possible to replace in the header of the word doc?
  • To post as a guest, your comment is unpublished.
    martinadam · 2 years ago
    Thanks for sharing this information with us.
    Word search and replace tool
  • To post as a guest, your comment is unpublished.
    nathalie · 2 years ago
    Works perfectly but is there a similar macro to change text in the header! because this does not work with this version!
    thanks
  • To post as a guest, your comment is unpublished.
    blds · 3 years ago
    Doesn't work for me on footers. e.g find FFSOSxxxx and replace with GGSOSxxxx, i can see this code is great for others pls help. :(
  • To post as a guest, your comment is unpublished.
    Kath · 3 years ago
    Hi there, is there a code for replacing with text that is multiple sentences, with bullet points and quotation marks in MS word using this code - which is fantastic !
  • To post as a guest, your comment is unpublished.
    keyvan · 3 years ago
    @keyvan sorry, i was wrong. the problem is that the number is in the header and it seems that the trick is not working in header. if i open one of the files and activate the header then run the module it works but just in that specific file ,even if i select all the files. thanks again.
  • To post as a guest, your comment is unpublished.
    keyvan · 3 years ago
    hi, i want to replace a number but i guess the problem that it's not working is that the number is not written in english it's in Persian. I would be so thankfull if someone can help me with it.
  • To post as a guest, your comment is unpublished.
    Asi · 3 years ago
    @Rav Put your files in one folder and select them all with a shift key. Hope this works.
  • To post as a guest, your comment is unpublished.
    Rav · 3 years ago
    Hi, I new to VBA. I am able to get the data updated for only single file. How to select multiple files when the VBA script opens up ? The question might be simple to few, but it will help. Since i need to update a string in 175+ plus word files. Appreciate your quick response. Thanks ...
  • To post as a guest, your comment is unpublished.
    darshan Jain · 3 years ago
    Hi
    this code is only editing 7 documents at a time... why?
  • To post as a guest, your comment is unpublished.
    Bryce · 3 years ago
    I really appreciated this post. Thank you. It allowed me to spend 10 minutes implementing something that saved several hours of work.
  • To post as a guest, your comment is unpublished.
    tomukosuryadi3@gmail.com · 3 years ago
    What if I want to find and replace multiple sentences in multiple documents?
  • To post as a guest, your comment is unpublished.
    3Cees · 3 years ago
    Thank you so much. You win the internet!

    This has saved me amending 360 documents.

    You're my favourite :)
  • To post as a guest, your comment is unpublished.
    blue_crayon · 3 years ago
    @Paul Oz You can edit the footer by using almost identical code that the header uses. Copy everything from "Begin Header Updates" to "End Header Updates" and paste it directly after.

    Then, in this pasted section, find the word "wdSeekCurrentPageHeader" and change it to "wdSeekCurrentPageFooter".
  • To post as a guest, your comment is unpublished.
    blue_crayon · 3 years ago
    @CC Was figuring out this issue myself, today.

    First, make sure you fix the line:

    Selection.Find.Replacement.Cle arFormatting

    To be:

    Selection.Find.Replacement.ClearFormatting

    Then, change the following line:

    If ActiveWindow.View.SplitSpecialwdPane None Then

    To look like this:

    If ActiveWindow.View.SplitSpecial <> wdPaneNone Then


    The code should look like this in the end:

    Windows(GetStr(j)).Activate
    Selection.Find.ClearFormatting
    Selection.Find.Replacement.ClearFormatting

    If ActiveWindow.View.SplitSpecial <> wdPaneNone Then
    ActiveWindow.Panes(2).Close
    End If

    If ActiveWindow.ActivePane.View.Type = wdNormalView Or ActiveWindow. _
    ActivePane.View.Type = wdOutlineView Then
    ActiveWindow.ActivePane.View.Type = wdPrintView
    End If
  • To post as a guest, your comment is unpublished.
    WAK · 3 years ago
    worked like a charm for me. Thanks a billion!
  • To post as a guest, your comment is unpublished.
    CC · 3 years ago
    Merlin 4099, I am having trouble with the following portion of your code. I am new to VBA.:

    ' --------------- --------------- --------------- ----------
    ' Beginning Header Updates
    ' --------------- --------------- --------------- ----------
    Windows(GetStr(j)).Activate
    Selection.Find.ClearFormatting
    Selection.Find.Replacement.Cle arFormatting

    If ActiveWindow.View.SplitSpecialwdPane None Then
    ActiveWindow.Panes(2).Close
    End If

    If ActiveWindow.ActivePane.View.Type = wdNormalView Or ActiveWindow. _
    ActivePane.View .Type = wdOutlineView Then

    Can anyone help me? I think I fixed most
  • To post as a guest, your comment is unpublished.
    CC · 3 years ago
    Merlin4099, I am having trouble with the following portion of your code:

    ' --------------- --------------- --------------- ----------
    ' Beginning Header Updates
    ' --------------- --------------- --------------- ----------
    Windows(GetStr(j)).Activate
    Selection.Find.ClearFormatting
    Selection.Find.Replacement.Cle arFormatting

    If ActiveWindow.View.SplitSpecialwdPane None Then
    ActiveWindow.Panes(2).Close
    End If

    If ActiveWindow.ActivePane.View.Type = wdNormalView Or ActiveWindow. _
    ActivePane.View .Type = wdOutlineView Then

    Can you or anyone else help me?

    Thanks!
  • To post as a guest, your comment is unpublished.
    DaveW · 3 years ago
    Thanks so much for posting this, absolute lifesaver!

    I notice that there is a line "MatchWildcards = False", which implies that it's possible to use wildcards in the search text - is that possible and, if so, what's the protocol?

    Thanks again!
  • To post as a guest, your comment is unpublished.
    Paul Oz · 4 years ago
    Hi all,
    I am new to the whole VBA thing and I Love love love this code!
    I have 5000+ docs to review and if this works it will save heaps of time!
    I have the code above running however i can see that it does not cater for replacing text in footers, Only headers and the body of the doc.
    Can anyone assist in extending this to the entire document.
    P.S. not sure if this is relevant but the list of words that i need to replace is the same for headers, footers and the body...
    Any help would really be appreciated!
  • To post as a guest, your comment is unpublished.
    Terence · 4 years ago
    Out of interest what does the line: Application.Run macroname:="NEW MACROS" do?
    The rest of the code makes sense to me (used to VBA in Excel) but I can't figure out why you need to execute another piece of code here.
    Thanks for the great tool though.
  • To post as a guest, your comment is unpublished.
    Ravini · 4 years ago
    @Merlin4099 To Merlin4099
    Wonderful code - thank you!! worked perfectly in executing what I needed.
  • To post as a guest, your comment is unpublished.
    Mike · 4 years ago
    This macro was amazing..is there any code to update multiple excel files,spss files.also is there is any macro to update the header and footer on multiple word documents .

    Any help is appreciated .thanks !
  • To post as a guest, your comment is unpublished.
    Tracy · 4 years ago
    Just brilliant, saved me lots of time, thank you
  • To post as a guest, your comment is unpublished.
    Exis · 4 years ago
    You can always try a 3rd party tool to do this which makes it very easy: www.officefindreplace.com
  • To post as a guest, your comment is unpublished.
    Nick · 4 years ago
    I am trying to add an entire section to a document that has three lines, bolding, and bullet points. Is there a way to keep that formatting when running the macro?
  • To post as a guest, your comment is unpublished.
    Tali1953 · 5 years ago
    To Merlin4099
    You have just saved my life (... time...) with you code !
    THANK YOU !!!
  • To post as a guest, your comment is unpublished.
    Jelena · 5 years ago
    Is it possible to change code and search and replace photo in multiply files?
  • To post as a guest, your comment is unpublished.
    fatma · 5 years ago
    this was sooo helpful, thank you very much! I have just changed the contents in 90 word files. This is amazing! Just one more tip: at the beginning close all open word documents but one of your file to be change.
  • To post as a guest, your comment is unpublished.
    Exis,LLC · 5 years ago
    You can use a program such as [url]www.officefindreplace.com[/url] to perform the same operation on multiple documents, or multiple operations on the same document. [url]www.officefindreplace.com[/url]
  • To post as a guest, your comment is unpublished.
    Merlin4099 · 5 years ago
    ' --- Beging body text replacemnt 3 ---
    With Selection.Find
    .Text = "leadership" ' Find What
    .Replacement.Text = "supervision" ' Replace With
    .Forward = True
    .Wrap = wdFindContinue
    .Format = False
    .MatchCase = False
    .MatchWholeWord = False
    .MatchByte = True
    .MatchWildcards = False
    .MatchSoundsLike = False
    .MatchAllWordForms = False
    End With
    Selection.Find.Execute Replace:=wdReplaceAll
    ' --- End body text replacemnt 3 ---

    Application.Run macroname:="NEWMACROS"
    ActiveDocument.Save
    ActiveWindow.Close
    ' -------------------------------------------------------
    ' End of Body Updates
    ' -------------------------------------------------------
    Next

    Application.ScreenUpdating = True

    End With

    MsgBox "operation end, please view", vbInformation

    End Sub
  • To post as a guest, your comment is unpublished.
    Merlin409 · 5 years ago
    ' --- Beging body text replacemnt 1 ---
    With Selection.Find
    .Text = "Body text 1" ' Find What
    .Replacement.Text = "BT1" ' Replace With
    .Forward = True
    .Wrap = wdFindContinue
    .Format = False
    .MatchCase = False
    .MatchWholeWord = False
    .MatchByte = True
    .MatchWildcards = False
    .MatchSoundsLike = False
    .MatchAllWordForms = False
    End With
    Selection.Find.Execute Replace:=wdReplaceAll
    ' --- Beging body text replacemnt 1 ---

    ' --- Beging body text replacemnt 2 ---
    With Selection.Find
    .Text = "membership" ' Find What
    .Replacement.Text = "team members" ' Replace With
    .Forward = True
    .Wrap = wdFindContinue
    .Format = False
    .MatchCase = False
    .MatchWholeWord = False
    .MatchByte = True
    .MatchWildcards = False
    .MatchSoundsLike = False
    .MatchAllWordForms = False
    End With
    Selection.Find.Execute Replace:=wdReplaceAll
    ' --- End body text replacemnt 2 ---
  • To post as a guest, your comment is unpublished.
    Merlin409 · 5 years ago
    ' --- Beging header text replacemnt 2 ---
    With Selection.Find
    .Text = "Header String 2" ' Find What
    .Replacement.Text = "HReplacement 2" ' Replace With
    .Forward = True
    .Wrap = wdFindContinue
    .Format = False
    .MatchCase = False
    .MatchWholeWord = False
    .MatchByte = True
    .MatchWildcards = False
    .MatchSoundsLike = False
    .MatchAllWordForms = False

    If .Found = True Then
    ChangeMade = True
    End If

    End With
    Selection.Find.Execute Replace:=wdReplaceAll
    ' --- Beging header text replacemnt 2 ---

    ActiveWindow.ActivePane.View.SeekView = wdSeekMainDocument
    ' ------------------------------------------------------
    ' End of Header Updates
    ' ------------------------------------------------------


    ' -------------------------------------------------------
    ' Beginning of Body Updates
    ' -------------------------------------------------------
    Windows(GetStr(j)).Activate
    Selection.Find.ClearFormatting
    Selection.Find.Replacement.ClearFormatting

    ' ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    ' Delete additional body replacement blocks if
    ' not needed or copy/paste additional blocks if
    ‘ required.
    ' ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  • To post as a guest, your comment is unpublished.
    Merlin409 · 5 years ago
    ' --- Beging header text replacemnt 1 ---
    With Selection.Find
    .Text = "Header String 1" ' Find What
    .Replacement.Text = "HReplacement 1" ' Replace With
    .Forward = True
    .Wrap = wdFindContinue
    .Format = False
    .MatchCase = False
    .MatchWholeWord = False
    .MatchByte = True
    .MatchWildcards = False
    .MatchSoundsLike = False
    .MatchAllWordForms = False

    If .Found = True Then
    ChangeMade = True
    End If

    End With
    Selection.Find.Execute Replace:=wdReplaceAll
    ' --- End header text replacemnt 1 ---
  • To post as a guest, your comment is unpublished.
    Merlin409 · 5 years ago
    Sub Search_and_Replace()

    ' 500 files is the maximum applying this code
    Dim MyDialog As FileDialog, GetStr(1 To 500) As String

    On Error Resume Next

    Set MyDialog = Application.FileDialog(msoFileDialogFilePicker)

    ' ---------------------------------------------------------------
    ' *.doc? allows processing of *.doc and *.docx files.
    ' ---------------------------------------------------------------
    With MyDialog
    .Filters.Clear
    .Filters.Add "All WORD File ", "*.doc?", 1
    .AllowMultiSelect = True

    i = 1
    If .Show = -1 Then
    For Each stiSelectedItem In .SelectedItems
    GetStr(i) = stiSelectedItem
    i = i + 1
    Next

    i = i - 1
    End If

    Application.ScreenUpdating = False

    For j = 1 To i Step 1
    Set Doc = Documents.Open(FileName:=GetStr(j), Visible:=True)

    ' -------------------------------------------------------
    ' Beginning Header Updates
    ' -------------------------------------------------------
    Windows(GetStr(j)).Activate
    Selection.Find.ClearFormatting
    Selection.Find.Replacement.ClearFormatting

    If ActiveWindow.View.SplitSpecial wdPaneNone Then
    ActiveWindow.Panes(2).Close
    End If

    If ActiveWindow.ActivePane.View.Type = wdNormalView Or ActiveWindow. _
    ActivePane.View.Type = wdOutlineView Then
    ActiveWindow.ActivePane.View.Type = wdPrintView
    End If

    ActiveWindow.ActivePane.View.SeekView = wdSeekCurrentPageHeader
    Selection.Find.ClearFormatting
    Selection.Find.Replacement.ClearFormatting
  • To post as a guest, your comment is unpublished.
    Merlin409 · 5 years ago
    I ran across this code while searching with DuckDuckGo. I modified it to suit my needs which were to other requests such as handling multiple search/replace in the header and multiple search/replace in the body. I also modified it handle the older .DOC format and the new .DOCX format. The modified code is pasted below. Feel free to use and improve!

    It is being sent in multiple parts because comments to this site can only be 2000 characters or less.
    ------------------------------------------------------------
  • To post as a guest, your comment is unpublished.
    Milo · 5 years ago
    This code has saved so much time for me... so, thanks!

    One thing though - is there any way to increase the number of words that the macro finds/replaces? I need to find/replace multiple paragraphs at once and the macro seems to have a limit of approximately 200 characters.
  • To post as a guest, your comment is unpublished.
    Mario · 6 years ago
    Is it possible to tweak this macro to perform multiple 'find and replace' stances at once? There are several words and phareses I need to replace and as of now I need to reinsert the VBA code for every instance.

    I'm a noob regarding those things
  • To post as a guest, your comment is unpublished.
    Moh · 6 years ago
    I've been testing it for the last few minutes and it's really a wonder, thank you!

    I need to perform several 'find and replace' routines for several files. Dozens of routines for dozens of files.

    Is there a way to 'save' the module so I don't need to paste it again on the VBA screen every time I need to perform a new routine?
  • To post as a guest, your comment is unpublished.
    Pia · 6 years ago
    I am sorry but I have no idea re the headers or the format. It was not something I needed to include in my code. I had never used this before myself and the code I posted was taken from the original code above and then tweeked using code found in other searches until it worked. I am sorry I cant be of more help.
  • To post as a guest, your comment is unpublished.
    sathena99 · 6 years ago
    Thanks for posting this! I've run a couple tests and gotten it to work for me; however, it's not working on text in headers and footers for some reason. Is there a fix for this?
  • To post as a guest, your comment is unpublished.
    WORDZ · 6 years ago
    Big THX 4 the code... but also have that prblm with the headers... no change

    Thanks in advance