View Single Post
 
Old 12-05-2012, 07:36 AM
vthomeschoolmom vthomeschoolmom is offline Windows 7 32bit Office 2010 32bit
Novice
 
Join Date: Feb 2012
Posts: 23
vthomeschoolmom is on a distinguished road
Default Macro for replacing, copying and undoing.

I use MS Word to basically work around a bunch of limitations in another piece of garbage application my company uses. I write macros to speed things I need to do. One macro I have is:

Code:
Sub ConvertSelectedNumberstoText()
'
' ConvertSelectedNumberstoText Macro
'
'
ActiveDocument.ConvertNumbersToText
With Selection.Find
  .Text = "^t"
  .Replacement.Text = " "
  .Forward = True
  .Wrap = wdFindAsk
  .Format = False
  .MatchCase = False
  .MatchWholeWord = False
  .MatchWildcards = False
  .MatchSoundsLike = False
  .MatchAllWordForms = False
  .Execute Replace:=wdReplaceAll
End With
Selection.Copy
ActiveDocument.Undo
End Sub
At the line in bold red above, Word prompts me with Word has reached the end of the document. x replacements were made. Do you want to continue searching at the beginning. I click no.

The text in my document that was previously copied is no longer selected, so the remainder of the macro does nothing useful. I think the copy line errors with a nothing is selected error.

What I want to know is if it is possible to perform the execute silently not continuing the search. I want it to leave my selection alone so that the remainder of the macro will complete.

Anyone have ideas? I see nothing obvious in the Execute method help.

Thanks

Last edited by macropod; 12-05-2012 at 03:38 PM. Reason: Added code tags & formatting
Reply With Quote