Re: Select several words
- From: "Graham Mayor" <gmayor@xxxxxxxxxxxxxxxxxx>
- Date: Thu, 14 Aug 2008 17:36:16 +0300
I cannot reproduce the comma issue here?
As for the rest replace the section
.Execute findText:=oldPart, _
ReplaceWith:="^&", _
Replace:=wdReplaceAll, _
MatchWildcards:=False, _
Forward:=True, _
Wrap:=wdFindContinue
with
..Execute findText:=oldPart, _
ReplaceWith:="^&", _
Replace:=wdReplaceAll, _
MatchWildcards:=False, _
Forward:=True, _
MatchWholeWord:=True, _
MatchCase:=True, _
Wrap:=wdFindContinue
Which will match whole words only
MatchWholeWord:=True, _
and make the search case sensitive
MatchCase:=True, _
--
<>>< ><<> ><<> <>>< ><<> <>>< <>><<>
Graham Mayor - Word MVP
My web site www.gmayor.com
Word MVP web site http://word.mvps.org
<>>< ><<> ><<> <>>< ><<> <>>< <>><<>
GM wrote:
Brillant! Thank you!
Two problems though:
Words in the document succeeded by a comma are not replaced
Parts of words in the document are also replaced, but I only want to
replace whole words (for example Bera in the list leads to a
replavement of the ending in Barbera)
"Graham Mayor" wrote:
Use the replace function in conjunction with a macro. Start with the
list of Words to be found in a single column table. Save the table
document and put the path and filename you have used in the line
marked that begins sFname = as shown.
Change or remove the formatting lines in the second marked section to
provide the formatting changes you want - the macro as shown will
format the found words as red coloured 14 point Arial bold italic.
Then run the following macro on the document you want to change
http://www.gmayor.com/installing_macro.htm
Sub ReplaceFromTableList()
Dim ChangeDoc As Document, RefDoc As Document
Dim cTable As Table
Dim oldPart As Range
Dim i As Long
Dim sFname As String
'********************************************
sFname = "D:\My Documents\Test\changes.doc"
'********************************************
Set RefDoc = ActiveDocument
Set ChangeDoc = Documents.Open(sFname)
Set cTable = ChangeDoc.Tables(1)
RefDoc.Activate
For i = 1 To cTable.Rows.Count
Set oldPart = cTable.Cell(i, 1).Range
oldPart.End = oldPart.End - 1
With Selection
.HomeKey wdStory
With .Find
.ClearFormatting
.Replacement.ClearFormatting
'****************************************
.Replacement.Font.Color = wdColorRed
.Replacement.Font.Size = "14"
.Replacement.Font.name = "Arial"
.Replacement.Font.Italic = True
.Replacement.Font.Bold = True
'****************************************
.Execute findText:=oldPart, _
ReplaceWith:="^&", _
Replace:=wdReplaceAll, _
MatchWildcards:=False, _
Forward:=True, _
Wrap:=wdFindContinue
End With
End With
Next i
ChangeDoc.Close wdDoNotSaveChanges
End Sub
--
<>>< ><<> ><<> <>>< ><<> <>>< <>><<>
Graham Mayor - Word MVP
My web site www.gmayor.com
Word MVP web site http://word.mvps.org
<>>< ><<> ><<> <>>< ><<> <>>< <>><<>
GM wrote:
Hi,
I have a long list of app. 1700 words that I have to find in my
Word-document, select and give another textcolour. It's a lot of
hours searching each and every word. Is there a way to search and
select occurrences of several words at a time.
Thanks in advance
.
- References:
- Select several words
- From: GM
- Re: Select several words
- From: Graham Mayor
- Re: Select several words
- From: GM
- Select several words
- Prev by Date: Reveal Codes
- Next by Date: Printing Errors
- Previous by thread: Re: Select several words
- Next by thread: Some formatting is lost when printing
- Index(es):
Relevant Pages
|