Tables

T

Tommysjerry Jerry

People I got a document which has several separate documents. In the
tables have the word "Ascane". I want the macros to mark the first
occurance of the word "Ascane" in each table. I have minimal computer
and macro knowledge pls someone help me in the code. I will be so so
so glad.
 
L

Lene Fredborg

I am not sure what you mean by "I got a document which has several separate
documents". However, I hope the macro below will help you.

The macro works on the active document. You do not tell in which way you
want the words to be marked. The macro will apply yellow highlight.

The macro will find the first occurrence of “Ascane†written with uppercase
A exactly as here. If you want to find the word regardless of the use of
uppercase and lowercase, remove the line “.MatchCase = True†from the macro.



Sub MarkWordAscane()
Dim oTable As Table
Dim strWord As String

'The word to find
strWord = "Ascane"

'Set highlight color to yellow
Options.DefaultHighlightColorIndex = wdYellow

'Check each table in the document
For Each oTable In ActiveDocument.Tables
'Find out whether strWord is found - keep the start position
With oTable.Range.Find
.Text = strWord
.Forward = True
.Wrap = wdFindStop
.MatchCase = True
.Replacement.Highlight = True
'make only one replacement in each table
.Execute Replace:=wdReplaceOne
End With
Next oTable

End Sub

If you need help on installing a macro, see:
http://word.mvps.org/faqs/macrosvba/CreateAMacro.htm

--
Regards
Lene Fredborg - Microsoft MVP (Word)
DocTools - Denmark
www.thedoctools.com
Document automation - add-ins, macros and templates for Microsoft Word
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top