Tip: Iné jazyky sú Google preložené. Môžete navštíviť English verziu tohto odkazu.
Prihlásiť sa
x
or
x
x
Registrovať
x

or

Ako vyhľadávať a nahrávať vo viacerých súboroch v slove?

Ak máte niekoľko desiatok súborov so súbormi, ktoré obsahujú rovnaký obsah (napríklad hlavička, päta, niektoré špeciálne slová alebo číslo) a musíte nahradiť ten istý obsah v týchto dokumentoch v programe Word. Ako by to bolo pre vás jednoduchšie, keby ste to urobili rýchlo? Samozrejme, môžete tieto súbory otvárať jeden po druhom, aby ste nahradili rovnaký obsah, ale bude to časovo náročné a nepríjemné. Tento výukový program vám ukáže, ako nahradiť rovnaký obsah vo viacerých dokumentoch v programe Word naraz.

Nájdite a nahraďte texty viacerými slovnými dokumentmi súčasne s kódom VBA


Jednoduché kombinovanie / zlúčenie viacerých dokumentov:

و Zlúčiť dokumenty užitočnosť Kutools pre Word vám môže pomôcť skombinovať viacero dokumentov do jedného. Stačí stačiť:

  • Vyberte dokumenty, ktoré budete kombinovať do jedného;
  • Zadajte prestávku medzi jednotlivými kombinovanými dokumentmi.
  • Začnite zlučovať. Pozri snímku obrazovky:

Kutools pre Word: s viac ako 100 užitočnými doplnkami programu Word, môžete skúsiť bez obmedzenia v dňoch 30. Stiahnite si bezplatnú skúšobnú verziu teraz!

Kutools pre Word: Pridať nové pokročilé funkcie 100 do programu Word 2003 / 2007 / 2010 / 2013 / 2016 / 2019.
Karta Office: Povoliť Úprava a prehliadanie v karte v kancelárii, Rovnako ako Chrome, Firefox, IE 8 / 9 / 10.
Klasická ponuka pre kanceláriu: Získajte starý vzhľad balíka Office 2003 do aplikácie Office 2007, 2010, 2013, 2016 a 2019.

Nájdite a nahraďte texty viacerými slovnými dokumentmi súčasne s kódom VBA

1. lis ostatné + F11 otvoriť Microsoft Visual Basic pre aplikácie okno.

2. V Microsoft Visual Basic pre aplikácie okno, kliknite na tlačidlo Vložiť > Moduly, potom skopírujte nasledujúci kód VBA do okna modulu.

Kód VBA: vyhľadávanie a nahradenie rovnakého obsahu vo viacerých dokumentoch naraz

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. Stlačte tlačidlo F5 kľúč na spustenie kódu.

4. V otvorení prezerať okno, nájdite a vyberte dokumenty, ktoré nájdete a nahraďte text vnútri a potom kliknite na tlačidlo OK Tlačidlo. Pozri snímku obrazovky:

5. V prvom Kutools pre Word dialógové okno zadajte text, ktorý nájdete medzi dokumentmi Nájsť to, čo a potom kliknite na tlačidlo OK tlačidlo.

6. V druhom Kutools pre Word dialógové okno zadajte text, ktorý chcete nahradiť, a kliknite na tlačidlo OK tlačidlo.

8. Kliknite na tlačidlo OK v ďalšom Microsoft Word dialógové okno dokončiť hľadanie a nahradiť.

V tomto prípade sú všetky slová "Word" vo vybratých dokumentoch nahradené súčasne "Excel".


Karta Office - Prehliadanie, editovanie a správa viacerých dokumentov v programe pomocou záložiek:

Karta Office prináša rozhranie s kartami, ako je vidieť vo webových prehliadačoch, ako sú prehliadače Google Chrome, nové verzie programu Internet Explorer a Firefox do aplikácie Microsoft Word. to vôľa je časovo úsporný nástroj a nenahraditeľný vo svojej práci. Pozrite si nižšie demo:

Kliknite na bezplatnú skúšobnú verziu aplikácie Office Tab!




Kutools pre Word

Viac ako rozšírené funkcie 100 pre aplikácie Word 2003, 2007, 2010, 2013, 2016 a 2019

Strela-Kutools-700-225, kt

Ďalšie funkcie | Bezplatné stiahnutie | Iba $ 39.00 pre stovky funkcií

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.
    Pia · 4 years ago
    It only runs across selected files and files must be in one folder only. This is run as a macro in a word doc. It is run from clicking a button. It only updates word doc's Hope this helps.


    Private Sub CommandButton1_Click()
    Dim MyDialog As FileDialog, GetStr(1 To 100) As String '100 files is the maximum applying this code
    On Error Resume Next
    Set MyDialog = Application.FileDialog(msoFileDialogFilePicker)
    With MyDialog
    .Filters.Clear
    '~~> Change this file extention to the relevant doc type.
    .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)
    Windows(GetStr(j)).Activate
    Selection.Find.ClearFormatting
    Selection.Find.Replacement.ClearFormatting

    For i = 1 To doc.Hyperlinks.Count
    'If the hyperlink matches.
    If LCase(doc.Hyperlinks(i).Address) = "http://www.yahoo.co.uk/" Then
    'Change the links address.
    doc.Hyperlinks(i).Address = "https://www.google.co.uk"
    'Change the links display text if desired.
    doc.Hyperlinks(i).TextToDisplay = "www.google.co.uk"
    End If
    Next
    Application.Run macroname:="NEWMACROS"
    ActiveDocument.Save
    ActiveDocument.Close
    Next
    Application.ScreenUpdating = True
    End With
    MsgBox "operation end, please view", vbInformation
    End Sub
  • To post as a guest, your comment is unpublished.
    Pia Wilson · 4 years ago
    You then add one of the following two sections depending on if it is test or hyperlink to be replaced

    '~~> This section if uncommented will replace text - ONLY ONE OF TWO SECTIONS CAN BE UNCOMMENTED AT ONCE


    With Selection.Find
    .Text = "www.google.co.uk" 'Find What
    .Replacement.Text = "www.google.com" '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
    ActiveDocument.Close
    Next
    Application.ScreenUpdating = True
    End With
    MsgBox "operation end, please view", vbInformation


    '~~> This section if uncommented will replace hyperlinks
    'For i = 1 To doc.Hyperlinks.Count
    ' 'If the hyperlink matches.
    ' If LCase(doc.Hyperlinks(i).Address) = "http://www.google.co.uk/" Then
    ' 'Change the links address.
    ' doc.Hyperlinks(i).Address = "https://www.google.com"
    ' 'Change the links display text if desired.
    ' doc.Hyperlinks(i).TextToDisplay = "www.google.com"
    ' End If
    ' Next
    'Application.Run macroname:="NEWMACROS"
    'ActiveDocument.Save
    'ActiveDocument.Close
    'Next
    'Application.ScreenUpdating = True
    'End With
    'MsgBox "operation end, please view", vbInformation



    End Sub
    • To post as a guest, your comment is unpublished.
      segarn · 4 years ago
      Hi Pia,
      I am trying to run your script for replacing hyperlinks but am getting errors. Any chance you can post the script for replacing hyperlinks all in 1 piece? I must be messing something up when trying to patch your code together.
  • To post as a guest, your comment is unpublished.
    Pia Wilson · 4 years ago
    This is what finally worked for me. I hope it helps. I added this macro to a word file. It will run the replace any documents selected (you can select as many as you like) when the file dialoge is open. It wont work on sub folders so I did each folder in the file structure individually but it worked.It may not be the best fix but it works at least.


    Private Sub CommandButton1_Click()
    Dim MyDialog As FileDialog, GetStr(1 To 100) As String '100 files is the maximum applying this code
    On Error Resume Next
    Set MyDialog = Application.FileDialog(msoFileDialogFilePicker)
    With MyDialog
    .Filters.Clear
    '~~> Change this file extention to the relevant doc type.
    .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)
    Windows(GetStr(j)).Activate
    Selection.Find.ClearFormatting
    Selection.Find.Replacement.ClearFormatting
    'Section then either one or the other of sections of code to follow.
  • To post as a guest, your comment is unpublished.
    Greg Simonis · 4 years ago
    I still cannot get this to work on my PC running Windows 7.
    When I run it, I get an error msg at the line:
    -Windows(GetStr(j)).Activate
    The error msg. is:
    -Compile error:
    -Sub or Function not defined
    Any idea why? And how to fix it?
  • 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.