Microsoft Office Forums

Go Back   Microsoft Office Forums > >

 
 
Thread Tools Display Modes
Prev Previous Post   Next Post Next
  #1  
Old 01-27-2015, 01:07 AM
streetcat streetcat is offline Help tweak the Macro Windows 7 64bit Help tweak the Macro Office 2010 64bit
Novice
Help tweak the Macro
 
Join Date: Jan 2015
Posts: 4
streetcat is on a distinguished road
Default Help tweak the Macro

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
My Requirement: To an extent, the above macro helped me. However, I am unable to easily eliminate offending phrases such as “It is recommended”. If I use quotation marks, macro is unable to find the phrase; if I don’t use the quotes, then macro is searching for all the words (it, is, and recommended).


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
Reply With Quote
 

Thread Tools
Display Modes


Similar Threads
Thread Thread Starter Forum Replies Last Post
Help tweak the Macro Macro Question: Need help making a macro to highlight the first word in every sentence 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
Help tweak the Macro New to Word 2010 and I need to tweak it for printing Bobosmite Word 1 07-01-2010 11:31 AM

Other Forums: Access Forums

All times are GMT -7. The time now is 09:22 AM.


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