Wenk: Ander tale is Google-vertaal. U kan die English weergawe van hierdie skakel.
Teken aan
x
or
x
x
registreer
x

or

Hoe om te soek en te vervang oor verskeie lêers in woord?

As jy 'n paar dosyn woordlêers bevat wat dieselfde inhoud bevat (soos Header, footer, 'n paar spesiale woorde of nommer), en jy moet dieselfde inhoud oor die dokumente in Word vervang. Hoe sal dit makliker wees om dit vinnig te doen? Sekerlik, jy kan die lêers een vir een oopmaak om dieselfde inhoud te vervang, maar dit sal tydrowend en lastig wees. Hierdie handleiding sal jou 'n moeilike manier wys om gelyktydig dieselfde inhoud binne verskeie dokumente in Word te vervang.

Vind en vervang tekste oor verskeie woorddokumente terselfdertyd met VBA-kode


Kombineer / voeg verskeie dokumente in een maklik by:

Die Voeg dokumente saam nut van Kutools for Word kan u help om verskeie dokumente vinnig in een te kombineer. Jy moet net:

  • Kies die dokumente wat u in een sal kombineer.
  • Spesifiseer die breek tussen elke gekombineerde dokument;
  • Begin saamsmelting. Sien skermkiekie:

Kutools for Word: met meer as 100 handige Word-invoegtoepassings, kan u sonder beperking in 30 dae probeer. Laai en gratis toets nou!

Kutools for Word: Voeg 100 nuwe gevorderde funksies by na Word 2003 / 2007 / 2010 / 2013 / 2016 / 2019.
Office Tab: Aktiveer Tabbed redigering en blaai in Office, Net soos Chrome, Firefox, IE 8 / 9 / 10.
Classic Menu for Office: Bring ou blik van kantoor 2003 terug na Office 2007, 2010, 2013, 2016 en 2019.

Vind en vervang tekste oor verskeie woorddokumente terselfdertyd met VBA-kode

1. Press alt + F11 om die Microsoft Visual Basic vir toepassings venster.

2. In die Microsoft Visual Basic vir toepassings venster, kliek Plaas > module, en kopieer dan die volgende VBA-kode na die Module-venster.

VBA-kode: Soek en vervang dieselfde inhoud oor verskeie dokumente op een slag

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. Druk die F5 sleutel om die kode uit te voer.

4. In die opening Kyk na venster, vind asseblief en kies die dokumente wat u sal vind en vervang teks binne, en klik dan op die OK knoppie. Sien skermkiekie:

5. In die eerste Kutools for Word dialoogkassie, voer die teks in wat jy oor dokumente sal vind in die Vind wat boks, en klik dan op die OK knoppie.

6. In die tweede Kutools for Word dialoog, voer die teks in wat u sal vervang, en klik op die OK knoppie.

8. Kliek die OK knoppie in die volgende Microsoft Word dialoogkassie om die soek te voltooi en te vervang.

In hierdie geval word alle woorde "Word" in geselekteerde dokumente terselfdertyd vervang met "Excel".


Office Tab - Tabbed navigeer, redigering en bestuur van verskeie dokumente in Word:

Office Tab bring die oortjie koppelvlak soos gesien in webblaaiers soos Google Chrome, Internet Explorer nuwe weergawes en Firefox na Microsoft Word. Dit sal wees 'n tydbesparende hulpmiddel en onvervangbaar in jou werk. Sien onderstaande demo:

Kliek vir gratis toets van die Office Tab!




Kutools for Word

Meer as 100 Gevorderde funksies vir Word 2003, 2007, 2010, 2013, 2016 en 2019

shot-kutools-700-225-kte

Meer funksies | Gratis aflaai | Slegs $ 39.00 vir honderde funksies

Say something here...
symbols left.
You are guest ( Sign Up? )
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.
    Muralisk · 4 years ago
    Worked like a charm and it did save a lot of time and effort for me. Thanks.
  • To post as a guest, your comment is unpublished.
    Pia Wilson · 4 years ago
    What I am trying to replace is a web address on our standard documents. I tried just doing finding the web address within the hyperlink but its not working as although this text has changed the view when not toggled to see the field code is still showing the old address.

    [b]EG[/b]
    With Selection.Find
    .Text = "HYPERLINK ""http://www.testsite.co.uk"" " 'Find What
    .Replacement.Text = "HYPERLINK ""http://www.testtwo.co.uk"" " 'Replace With
  • To post as a guest, your comment is unpublished.
    Greg Simonis · 5 years ago
    When I run it, it gets hung up and stops at:
    Application.Run macroname:="NEWMACROS"
    and when I step into it, it tells me I have a Compile error: Named argument not found.
    Now what?
  • To post as a guest, your comment is unpublished.
    Jebidiah Springfield · 5 years ago
    Wow you are a saint for putting this macro together! I am listening to 'Epic Battle Music' on Songza because I am such an amatuer Macro-smith and it's the only way I can make it through the pain and agony of crafting programming spells.

    Anyway, my point I am going to make is a spent a lot of time on Friday troubleshooting the part where you actually put in the text you want to find and putting in the text you want to replace - I did not quite understand this part in terms of where I put my "find" word text and "replace" word text:

    [quote]Note:you can change the Text = "search”, Replacement.Text = "find” to specify the content to be searched and the content to be applied for replacement.
    [/quote]

    I read over this again today and I wish to respectfully clarify for other programming non-initiates - in the section of VBA where you have copied and pasted the original programming language, make sure you put an end ' after the [i]what [/i] and a ' after the [i]with[/i] (see example below) - in my example, I am looking for multiple documents to replace Pizza with Stromboli:

    .Text = "Pizza" 'Find What'
    .Replacement.Text = "Stromboli" 'Replace With'
  • To post as a guest, your comment is unpublished.
    James R · 5 years ago
    Could this VBA technique be adapted to work for Publisher files? For example by changing *.docx to *.pub ?