Skip i'r prif gynnwys

Sut i chwilio a newid ffeiliau lluosog mewn gair?

Os oes gennych sawl dwsin o ffeiliau geiriau sy'n cynnwys yr un cynnwys (fel Pennawd, troedyn, rhai geiriau neu rif arbennig), ac mae angen i chi ddisodli'r un cynnwys ar draws y dogfennau hynny yn Word. Sut y byddai'n haws ichi ei wneud yn gyflym? Yn sicr, gallwch agor y ffeiliau hynny fesul un i ddisodli'r un cynnwys, ond bydd yn cymryd llawer o amser ac yn drafferthus. Bydd y tiwtorial hwn yn dangos ffordd anodd i chi ddisodli'r un cynnwys mewn sawl dogfen yn Word ar unwaith.

Dod o hyd i destunau ar draws sawl dogfen ar yr un pryd â chod VBA
Darganfod a disodli gwahanol destunau yn hawdd ar draws sawl dogfen ar yr un pryd â Kutools ar gyfer Word


Dod o hyd i destunau ar draws sawl dogfen ar yr un pryd â chod VBA

1. Gwasgwch Alt + F11 i agor y Microsoft Visual Basic ar gyfer Ceisiadau ffenestr.

2. Yn y Microsoft Visual Basic ar gyfer Ceisiadau ffenestr, cliciwch MewnosodModiwlau, yna copïwch y cod VBA canlynol i mewn i ffenestr y Modiwl.

Cod VBA: Chwilio ac ailosod yr un cynnwys ar draws sawl dogfen ar yr un pryd

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. Gwasgwch y F5 allwedd i redeg y cod.

4. Yn yr agoriad Pori ffenestr, dewch o hyd i a dewis y dogfennau y byddwch yn dod o hyd iddynt a newid testun y tu mewn, ac yna cliciwch ar y OK botwm. Gweler y screenshot:

5. Yn y cyntaf Kutools am Word blwch deialog, nodwch y testun y byddwch yn dod o hyd iddo ar draws dogfennau yn y Dewch o hyd i beth blwch, ac yna cliciwch ar y OK botwm.

6. Yn yr ail Kutools am Word blwch deialog, nodwch y testun y byddwch yn ei ddisodli, a chliciwch ar y OK botwm.

8. Cliciwch ar y OK botwm yn y nesaf Microsoft Word blwch deialog i orffen y darganfyddiad a'i ailosod.

Yn yr achos hwn, mae "Excel" yn disodli'r holl eiriau "Word" mewn dogfennau dethol ar yr un pryd.


Darganfod a disodli gwahanol destunau yn hawdd ar draws sawl dogfen ar yr un pryd â Kutools ar gyfer Word

Yma yn argymell yn fawr y Swp Dod o Hyd i ac Amnewid nodwedd o Kutools am Word. Gyda'r nodwedd hon, gallwch chi ddod o hyd i destunau gwahanol a'u disodli'n hawdd ar draws sawl dogfen Word yr un amser. Dewch i ni weld sut i gymhwyso'r nodwedd hon i ddod o hyd i destunau a'u disodli ar draws dogfennau.

Kutools am Word : gyda mwy na 100 o ychwanegion Word defnyddiol, rhydd i geisio heb unrhyw gyfyngiad yn 60 diwrnod.

1. Cliciwch Kutools Byd Gwaith > Swp Dod o Hyd i ac Amnewid i alluogi'r nodwedd.

2. Yn y Swp Dod o Hyd i ac Amnewid blwch deialog, ffurfweddwch fel a ganlyn.

  • 2.1) Cliciwch y Ychwanegu Row botwm o dan y Dod o hyd ac yn ei le tab;
  • 2.2) Yn y meysydd rhes a grëwyd:
A. Rhowch y testun y byddwch yn dod o hyd iddo yn y blwch testun yn y Dod o hyd i colofn
B. Rhowch y testun y byddwch yn ei ddisodli yn y blwch testun yn y Disodli colofn;
C. Nodwch fath chwilio, ble i ddod o hyd i'r testun a lliw i dynnu sylw at y testun yn ôl yr angen. Yn yr achos hwn, dewisaf Paru geiriau llawn, Prif ddogfen a lliw penodol o'r Math Chwilio, Dewch o hyd i mewn ac Amlygu colofnau;
  • 2.3) Ailadroddwch gam 2.1 a 2.2 i ychwanegu mwy o destunau y byddwch yn dod o hyd iddynt ac yn eu disodli;
  • 2.4) Cliciwch y  botwm yn y Math o ffeil adran i ychwanegu'r dogfennau Word lle byddwch chi'n dod o hyd i destunau ac yn eu lle;
  • 2.5) Cliciwch y Disodli or Dod o hyd i botwm. Gweler y screenshot:

Nodiadau:
1. Os cliciwch y Dod o hyd i botwm, bydd yr holl ganlyniadau darganfod yn cael eu harddangos o dan y Canlyniad Rhagolwg tab. Ar ôl cael rhagolwg o'r canlyniadau, os ydych chi am ailosod pob testun, cliciwch y Dod o hyd ac yn ei le tab. Fel arall, caewch y dialog.

2. Os cliciwch y Disodli botwm, bydd pob testun penodol yn cael ei ddisodli â rhai newydd ar unwaith, a bydd y canlyniadau hefyd yn cael eu harddangos o dan y Canlyniad Rhagolwg tab.

3. Os nodwch liwiau uchafbwyntiau yng ngham 2, bydd lliwiau penodol yn tynnu sylw at yr holl destunau a ddisodlwyd, a gallwch ddod o hyd iddynt yn hawdd mewn cipolwg mewn dogfennau.

3. Caewch y Swp Dod o Hyd i ac Amnewid blwch deialog

I gael mwy o wybodaeth am y nodwedd hon, os gwelwch yn dda cliciwch yma ....

Os ydych chi am gael treial am ddim o'r cyfleustodau hwn, ewch i dadlwythwch y meddalwedd am ddim yn gyntaf, ac yna ewch i gymhwyso'r llawdriniaeth yn ôl y camau uchod.

Offer Cynhyrchiant Swyddfa Gorau

Kutools am Word - Dyrchafu Eich Profiad Word gyda Dros 100 Nodweddion Rhyfeddol!

🤖 Cynorthwy-ydd Kutools AI: Trawsnewidiwch eich ysgrifennu gydag AI - Cynhyrchu Cynnwys  /  Ailysgrifennu Testun  /  Crynhoi Dogfennau  /  Ymholwch am Wybodaeth yn seiliedig ar Ddogfen, i gyd o fewn Word

📘 Meistrolaeth Dogfen: Tudalennau Hollti  /  Uno Dogfennau  /  Dewis Allforio mewn Fformatau Amrywiol (PDF/TXT/DOC/HTML...)  /  Trosi swp i PDF  /  Allforio Tudalennau fel Delweddau  /  Argraffu Ffeiliau Lluosog ar unwaith...

Golygu Cynnwys: Swp Dod o Hyd i ac Amnewid ar draws Ffeiliau Lluosog  /  Newid Maint Pob Llun  /  Trawsosod Rhesi Bwrdd a Cholofnau  /  Trosi Tabl i Testun...

🧹 Ymdrech Glân: swap i ffwrdd Mannau Ychwanegol  /  Toriadau Adran  /  Pob Pennawd  /  Blychau Testun  /  hypergysylltiadau  / Am fwy o offer tynnu, ewch i'n Dileu Grŵp...

Mewnosodiadau Creadigol: mewnosod Mil o Wahanwyr  /  Blychau Gwirio  /  Botymau Radio  /  Cod QR  /  Cod Bar  /  Tabl Llinell Lletraws  /  Pennawd Hafaliad  /  Capsiwn Delwedd  /  Pennawd Tabl  /  Lluniau Lluosog  / Darganfod mwy yn y Mewnosod Grŵp...

🔍 Detholiadau Manwl: pinbwynt tudalennau penodol  /  tablau  /  siapiau  /  paragraffau pennawd  / Gwella llywio gyda mwy Dewiswch nodweddion...

Gwelliannau Seren: Llywiwch yn gyflym i unrhyw leoliad  /  auto-mewnosod testun ailadroddus  /  toglo'n ddi-dor rhwng ffenestri dogfennau  /  11 Offer Trosi...

???? Eisiau rhoi cynnig ar y nodweddion hyn? Mae Kutools ar gyfer Word yn cynnig a Treial am ddim 60-dydd, heb unrhyw gyfyngiadau! 🚀
 
Comments (70)
No ratings yet. Be the first to rate!
This comment was minimized by the moderator on the site
thanks for -How To Search And Replace Across Multiple Files In Word?

what about from out side (by folder) ?

thanks gain
This comment was minimized by the moderator on the site
This is a great explanation.  Is there a way to change settings, e.g. page size, simultaneously? 
This comment was minimized by the moderator on the site
After pressing F5, I get the following error" "Compile error: User-defined type not defined." Can someone help?
This comment was minimized by the moderator on the site
Hi Monique,Please check if the Microsoft Office Object Library is enabled as shown in the screenshot below.
This comment was minimized by the moderator on the site
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?
This comment was minimized by the moderator on the site
I need to replace text in multiple Word files and have the replaced text highlighted. Is there a way to do this?
This comment was minimized by the moderator on the site
Hi Daphne,
Why not try the Batch Find and Replace feature of Kutools for Word? It can solve this issue with ease.
This comment was minimized by the moderator on the site
this was a lifesaver thank you so much
This comment was minimized by the moderator on the site
Is it possible to replace in the headers of the word doc?
This comment was minimized by the moderator on the site
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
This comment was minimized by the moderator on the site
Is that possible to replace in the header of the word doc?
This comment was minimized by the moderator on the site
Thanks for sharing this information with us.
Word search and replace tool
This comment was minimized by the moderator on the site
Works perfectly but is there a similar macro to change text in the header! because this does not work with this version!
thanks
This comment was minimized by the moderator on the site
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
This comment was minimized by the moderator on the site
Oh yeah! Thank you sooooo much! This is a life-saver!
There are no comments posted here yet
Load More
Please leave your comments in English
Posting as Guest
×
Rate this post:
0   Characters
Suggested Locations