![]() |
#1
|
|||
|
|||
![]()
Hi All,
My requirement: Certain words should not appear in our company publications such as Vice versa, &, in-built, and ad hoc. What I have done so far: I have created a table with just one Colum (in a word doc, of course!), and typed all the offending words. Then I executed the following macro: Code:
Sub Highlighting() Dim oChanges As Document, oDoc As Document Dim oTable As Table Dim oRng As Range Dim rFindText As Range Dim i As Long Dim sFname As String sFname = "location of the file" Set oDoc = ActiveDocument Set oChanges = Documents.Open(FileName:=sFname, Visible:=False) Set oTable = oChanges.Tables(1) For i = 1 To oTable.Rows.Count Set oRng = oDoc.Range Set rFindText = oTable.Cell(i, 1).Range rFindText.End = rFindText.End - 1 With oRng.Find .ClearFormatting .Replacement.ClearFormatting Do While .Execute(FindText:=rFindText, _ MatchWholeWord:=True) = True oRng.HighlightColorIndex = wdBrightGreen Loop End With Next i oChanges.Close wdDoNotSaveChanges End Sub Can someone help me tweak this macro? Thanks in advance, Streetcat Last edited by streetcat; 01-27-2015 at 03:15 AM. Reason: Code wrapped as suggested by macropod |
|
![]() |
||||
Thread | Thread Starter | Forum | Replies | Last Post |
![]() |
LadyAna | Word | 1 | 12-06-2014 10:39 PM |
Macro Needed to bold specific lines and Macro to turn into CSV | anewteacher | Word VBA | 1 | 05-28-2014 03:59 PM |
custom icon, undo/redo for macro, permanent macro | Rapier | Excel | 0 | 08-05-2013 06:30 AM |
How do I assign a macro to a button when the macro is in my personal workbook? | foolios | Excel Programming | 2 | 07-27-2011 02:41 PM |
![]() |
Bobosmite | Word | 1 | 07-01-2010 11:31 AM |