Padoms. Citas valodas ir Google tulkotas. Jūs varat apmeklēt English šīs saites versiju.
Pieslēgties
x
or
x
x
Reģistrēties
x

or

Kā meklēt un aizstāt vārdus vairākos failos?

Ja jums ir vairāki desmiti vārdu faili, kas satur to pašu saturu (piemēram, galveni, kājene, daži īpaši vārdi vai numurs), un jums ir jāmaina viens un tas pats saturs šajos dokumentos programmā Word. Kā jums būtu vieglāk to izdarīt ātri? Protams, jūs varat atvērt šos failus pa vienam, lai aizstātu to pašu saturu, taču tas būs laikietilpīgs un apgrūtinošs. Šī apmācība parādīs grūts veids, kā vienlaikus aizstāt to pašu saturu vairākos dokumentos Word.

Atrodiet un aizstājiet tekstu vairākos vārdu dokumentos vienlaikus ar VBA kodu


Vienkārši apvienojiet / apvienojiet vairākus dokumentus:

The Dokumentu apvienošana lietderība Kutools par Word var palīdzēt ātri apvienot vairākus dokumentus vienā. Jums vienkārši nepieciešams:

  • Atlasiet dokumentus, kurus jūs apvienojat vienā;
  • Norādiet pārtraukumu starp katru kombinēto dokumentu;
  • Sāciet saplūšanu. Skatīt ekrānuzņēmumu:

Kutools par Word: ar vairāk nekā 100 parocīgiem Word pievienojumprogrammām, varat brīvi izmēģināt bez ierobežojumiem 30 dienās. Lejupielādēt un bezmaksas izmēģinājuma versija tūlīt!

Kutools par Word: Pievienojiet 100 jaunas uzlabotas funkcijas uz Word 2003 / 2007 / 2010 / 2013 / 2016 / 2019.
Cilnē Office: Iespējot Tabbed Rediģēšana un pārlūkošana Office, Just Like Chrome, Firefox, IE 8 / 9 / 10.
Classic Menu Office: Noved Office 2003 atpakaļ uz Office 2007, 2010, 2013, 2016 un 2019.

Atrodiet un aizstājiet tekstu vairākos vārdu dokumentos vienlaikus ar VBA kodu

1. Nospiediet cits + F11 lai atvērtu Microsoft Visual Basic for Applications logs.

2. Iekš Microsoft Visual Basic for Applications logs, noklikšķiniet uz ielaidums > Moduļi, pēc tam kopējiet nākamo VBA kodu moduļa logā.

VBA kods: vienlaikus tiek meklēts un aizstāts viens un tas pats saturs vairākos dokumentos

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. Nospiediet F5 taustiņš, lai palaistu kodu.

4. Atklāšanā Pārlūkot logu, atrodiet un atlasiet atrodamos dokumentus un aizvietojiet tekstu iekšā un pēc tam noklikšķiniet uz OK poga Skatīt ekrānuzņēmumu:

5. Pirmajā Kutools par Word dialoglodziņā ievadiet tekstu, kuru jūs atradīsiet pāri dokumentiem Atrast to, ko lodziņā un pēc tam noklikšķiniet uz OK poga.

6. Otrajā Kutools par Word dialoglodziņā ievadiet tekstu, kuru jūs aizstāsiet, un noklikšķiniet uz OK poga.

8. Noklikšķiniet OK pogas nākamajā Microsoft Word dialoglodziņš, lai pabeigtu meklēšanu un aizstātu.

Šajā gadījumā vienlaikus visi vārdi "Word" atlasītajos dokumentos tiek aizstāti ar "Excel".


Cilnē Office - Vairāku dokumentu Word, izmantojot tabbed pārlūkošanu, rediģēšanu un pārvaldīšanu:

Office cilnē tiek parādīts cilnes interfeiss, kas redzams tīmekļa pārlūkprogrammās, piemēram, Google Chrome, Internet Explorer jaunās versijās un Firefox uz Microsoft Word. Tas griba esi laikmeta saglabāšanas rīks un neaizvietojams darbā. Skatīt demo zemāk:

Noklikšķiniet, lai saņemtu Office Tab bezmaksas izmēģinājumu!




Kutools par Word

Vairāk nekā 100 uzlabotās funkcijas Word 2003, 2007, 2010, 2013, 2016 un 2019

shot-kutools-700-225-kte

Vairāk funkciju | Bezmaksas lejupielāde | Tikai $ 39.00 simtiem funkciju

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.
    Merlin4099 · 3 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.
      Ravini · 2 years ago
      To Merlin4099
      Wonderful code - thank you!! worked perfectly in executing what I needed.
  • To post as a guest, your comment is unpublished.
    Merlin409 · 3 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 · 3 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 · 3 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 · 3 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