A
A
Anatoly Sidorov2016-05-13 18:29:47
Visual Basic
Anatoly Sidorov, 2016-05-13 18:29:47

Quick find and replace in Word?

Good afternoon!
If the document is ~350 pages. At the end of the document (only on the last pages) there are unique marks like p***p, *** - corresponds to any value from the dictionary. The task is to replace these labels with their dictionary equivalents and change their color to black.
Here is an example written:

For Each Key In dic.Keys
  newText = dic.Item(Key)

  objWrd.Selection.EndKey 'т.к. странице лежат в конце, начинаем поиск оттуда
  With objWrd.Selection.Find
    .ClearFormatting
    .Replacement.ClearFormatting
    .Text = Key
    .Replacement.Text = newText
    .Forward = True
    .Wrap = 2
    .Format = False
    .MatchCase = False
    .MatchWholeWord = False
  End With
  
  objWrd.Selection.Find.Execute , , , , , , , , , , 1
  objWrd.Selection.Font.Color = -587137025
Next

It works, but very slowly, on a working machine 10-15 minutes.
What are the options to speed up the work of search and replace?
Thanks in advance.

Answer the question

In order to leave comments, you need to log in

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question