Microsoft Office Forums

Go Back   Microsoft Office Forums > >

Reply
 
Thread Tools Display Modes
  #1  
Old 03-19-2013, 03:49 PM
macropod's Avatar
macropod macropod is offline Word VBA - Search a word and add/remove it Windows 7 64bit Word VBA - Search a word and add/remove it Office 2010 32bit
Administrator
 
Join Date: Dec 2010
Location: Canberra, Australia
Posts: 22,467
macropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond repute
Default

Try something like:
Code:
Sub Demo()
Application.ScreenUpdating = False
Dim Tbl As Table, FndList, RepList, i As Long
FndList = Array("Replace", "Do")
RepList = Array("Replaced", "Done")
With ActiveDocument
  For Each Tbl In .Tables
    With Tbl.Range.Find
      .ClearFormatting
      .Replacement.ClearFormatting
      .MatchWholeWord = True
      .Replacement.Text = "^&"
      .Wrap = wdFindStop
      For i = 0 To UBound(FndList)
        .Text = FndList(i)
        .Replacement.Text = RepList(i)
        .Execute Replace:=wdReplaceAll
      Next
    End With
  Next
End With
Application.ScreenUpdating = True
End Sub
The above code only looks in tables in the body of the document. To add more Find/Replace expressions, simply edit the two arrays - FndList & RepList.
__________________
Cheers,
Paul Edstein
[Fmr MS MVP - Word]
Reply With Quote
Reply



Similar Threads
Thread Thread Starter Forum Replies Last Post
search on multiple word documents Guy Roth Word 7 03-06-2017 01:31 PM
Word VBA - Search a word and add/remove it Word: Search and fill from Excel gbrucken Word 1 04-30-2012 10:40 AM
Word VBA - Search a word and add/remove it Remove numbering from Word Doc antaeusguy Word 1 03-14-2012 04:01 AM
Word VBA - Search a word and add/remove it search option in word 2007 anano Word 1 01-11-2012 09:03 AM
Search Problems in MS Word LoganB Word 0 09-03-2010 06:49 AM

Other Forums: Access Forums

All times are GMT -7. The time now is 10:01 PM.


Powered by vBulletin® Version 3.8.11
Copyright ©2000 - 2025, vBulletin Solutions Inc.
Search Engine Optimisation provided by DragonByte SEO (Lite) - vBulletin Mods & Addons Copyright © 2025 DragonByte Technologies Ltd.
MSOfficeForums.com is not affiliated with Microsoft