find/replace macro will not complete

D

dawntreader

Identical copies of a lenghty (1100 line) find/replace macro is set up on
multiple PC's all of which are running the same version of Word 2003. On the
vast majority of the user's systems, the macro executes to completion with no
required input from the user. On the systems of a small number of users, the
macro stops after each find/replace action and returns a message to the
effect that Word has finished searching the document - do you want to start
over at the beginning? Y/N This requires the user to hit the ENTER key many
times to complete the running of the macro. Since all instances of Word are
the same version and all copies of the macro are identical, what user setting
is causing the the macro not to fully execute without user input.
 
H

Helmut Weber

Hi,

are you sure, that when searching with the selection-object
all options are reset before starting the search?
Resetting them afterwards would be a good idea, too.

Public Sub ResetSearch()
With Selection.Find
.ClearFormatting
.Replacement.ClearFormatting
.Text = ""
.Replacement.Text = ""
.Forward = True
.Wrap = wdFindContinue
.Format = False
.MatchCase = False
.MatchWholeWord = False
.MatchWildcards = False
.MatchSoundsLike = False
.MatchAllWordForms = False
.Execute
End With
End Sub


--
Greetings from Bavaria, Germany

Helmut Weber, MVP WordVBA

Win XP, Office 2003
"red.sys" & Chr$(64) & "t-online.de"
 
D

dawntreader

Thank you, Helmut.

I'm not sure and will look at the code for this at each instance. I
complied the macro from blocks of recorded code and may not have the reset at
each new execution. It is a series of find/replace, add line break tasks
that takes raw XML email feeds that we are getting and removes the markup
tags and reformats with line breaks. I have just been stumped and mystified
over why it behaves differently in what appear to identical environments.

Thank you again.

Carl
 
H

Helmut Weber

Hi,

maybe one more word for clarification,

if you do a number of search and replace operations,
and the settings as defined in "resetsearch" fit the
needs of all the replacements,
it is sufficient to reset options once, before the first search.

Once options are set, let's say manually by a user,
selection.find remembers the last settings and continues
to use them until they are changed.
 

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