Thread: macro problems
View Single Post
  #7   Report Post  
Stephen Larivee
 
Posts: n/a
Default

Thank you. I will give this a try. I will also look at the strip mail
utility at your web site.

Thanks again.






"Graham Mayor" wrote in message
...
The problem is with the first line of your macro - selection.whole story.
Remove that line.

There are several bits of your macro that are unnecessary and some bits
that
don't do anything. You could also reduce the number of steps by using
wildcards http://www.gmayor.com/replace_using_wildcards.htm - and get rid
of all of it by using the stripmail utility linked from the downloads page
of my web site - but to tidy up your code to what I think you intended:

Sub CleanPartial()
' Macro recorded 1/25/2005 by Stephen Larivee
'
Selection.Find.ClearFormatting
Selection.Find.Replacement.ClearFormatting
With Selection.Find
.Font.Name = "Times New Roman"
.Font.Size = 12
.Text = ""
.Replacement.Text = ""
.Forward = True
.Wrap = wdFindStop
.Format = False
.MatchCase = False
.MatchWholeWord = False
.MatchWildcards = False
.MatchSoundsLike = False
.MatchAllWordForms = False
End With
Selection.Find.Execute replace:=wdReplaceAll
With Selection.Find
.Text = "~"
.Replacement.Text = ""
End With
Selection.Find.Execute replace:=wdReplaceAll
With Selection.Find
.Text = "^l"
.Replacement.Text = "^p"
End With
Selection.Find.Execute replace:=wdReplaceAll
With Selection.Find
.Text = " ^p"
.Replacement.Text = "^p"
End With
Selection.Find.Execute replace:=wdReplaceAll
With Selection.Find
.Text = "^p "
.Replacement.Text = "^p"
End With
Selection.Find.Execute replace:=wdReplaceAll

'**********************************************
'what is this section supposed to be doing?
With Selection.Find
.Text = "'"
.Replacement.Text = "'"
End With
Selection.Find.Execute replace:=wdReplaceAll

'and this

With Selection.Find
.Text = """"
.Replacement.Text = """"
End With
Selection.Find.Execute replace:=wdReplaceAll
'************************************************* *

With Selection.Find
.Text = "^p^p^p"
.Replacement.Text = "^p^p"
End With
Selection.Find.Execute replace:=wdReplaceAll
With Selection.Find
.Text = "^p^p"
.Replacement.Text = "~~~~"
End With
Selection.Find.Execute replace:=wdReplaceAll
With Selection.Find
.Text = "^p"
.Replacement.Text = " "
End With
Selection.Find.Execute replace:=wdReplaceAll
With Selection.Find
.Text = "~~~~"
.Replacement.Text = "^p^p"
End With
Selection.Find.Execute replace:=wdReplaceAll
With Selection.Find
.Text = " "
.Replacement.Text = " "
End With
Selection.Find.Execute replace:=wdReplaceAll
End Sub


--

Graham Mayor - Word MVP

My web site www.gmayor.com
Word MVP web site http://word.mvps.org





Stephen Larivee wrote:
I tried replacing all of the wdFindContinue with wdFindStop but the
problem continues.

CleanPartial Macro
' Macro recorded 1/25/2005 by Stephen Larivee
'
Selection.WholeStory
Selection.Font.Name = "Times New Roman"
Selection.Font.Size = 12
Selection.HomeKey Unit:=wdStory
Selection.Find.ClearFormatting
Selection.Find.Replacement.ClearFormatting
With Selection.Find
.Text = ""
.Replacement.Text = ""
.Forward = True
.Wrap = wdFindStop
.Format = False
.MatchCase = False
.MatchWholeWord = False
.MatchWildcards = False
.MatchSoundsLike = False
.MatchAllWordForms = False
End With
Selection.Find.Execute Replace:=wdReplaceAll
With Selection.Find
.Text = "~"
.Replacement.Text = ""
.Forward = True
.Wrap = wdFindStop
.Format = False
.MatchCase = False
.MatchWholeWord = False
.MatchWildcards = False
.MatchSoundsLike = False
.MatchAllWordForms = False
End With
Selection.Find.Execute Replace:=wdReplaceAll
With Selection.Find
.Text = "^l"
.Replacement.Text = "^p"
.Forward = True
.Wrap = wdFindStop
.Format = False
.MatchCase = False
.MatchWholeWord = False
.MatchWildcards = False
.MatchSoundsLike = False
.MatchAllWordForms = False
End With
Selection.Find.Execute Replace:=wdReplaceAll
With Selection.Find
.Text = " ^p"
.Replacement.Text = "^p"
.Forward = True
.Wrap = wdFindStop
.Format = False
.MatchCase = False
.MatchWholeWord = False
.MatchWildcards = False
.MatchSoundsLike = False
.MatchAllWordForms = False
End With
Selection.Find.Execute Replace:=wdReplaceAll
Selection.Find.Execute Replace:=wdReplaceAll
Selection.Find.Execute Replace:=wdReplaceAll
Selection.Find.Execute Replace:=wdReplaceAll
With Selection.Find
.Text = "^p "
.Replacement.Text = "^p"
.Forward = True
.Wrap = wdFindStop
.Format = False
.MatchCase = False
.MatchWholeWord = False
.MatchWildcards = False
.MatchSoundsLike = False
.MatchAllWordForms = False
End With
Selection.Find.Execute Replace:=wdReplaceAll
Selection.Find.Execute Replace:=wdReplaceAll
Selection.Find.Execute Replace:=wdReplaceAll
Selection.Find.Execute Replace:=wdReplaceAll
With Selection.Find
.Text = "'"
.Replacement.Text = "'"
.Forward = True
.Wrap = wdFindStop
.Format = False
.MatchCase = False
.MatchWholeWord = False
.MatchWildcards = False
.MatchSoundsLike = False
.MatchAllWordForms = False
End With
Selection.Find.Execute Replace:=wdReplaceAll
With Selection.Find
.Text = """"
.Replacement.Text = """"
.Forward = True
.Wrap = wdFindStop
.Format = False
.MatchCase = False
.MatchWholeWord = False
.MatchWildcards = False
.MatchSoundsLike = False
.MatchAllWordForms = False
End With
Selection.Find.Execute Replace:=wdReplaceAll
With Selection.Find
.Text = "^p^p^p"
.Replacement.Text = "^p^p"
.Forward = True
.Wrap = wdFindStop
.Format = False
.MatchCase = False
.MatchWholeWord = False
.MatchWildcards = False
.MatchSoundsLike = False
.MatchAllWordForms = False
End With
Selection.Find.Execute Replace:=wdReplaceAll
Selection.Find.Execute Replace:=wdReplaceAll
Selection.Find.Execute Replace:=wdReplaceAll
Selection.Find.Execute Replace:=wdReplaceAll
Selection.Find.Execute Replace:=wdReplaceAll
With Selection.Find
.Text = "^p^p"
.Replacement.Text = "~~~~"
.Forward = True
.Wrap = wdFindStop
.Format = False
.MatchCase = False
.MatchWholeWord = False
.MatchWildcards = False
.MatchSoundsLike = False
.MatchAllWordForms = False
End With
Selection.Find.Execute Replace:=wdReplaceAll
With Selection.Find
.Text = "^p"
.Replacement.Text = " "
.Forward = True
.Wrap = wdFindStop
.Format = False
.MatchCase = False
.MatchWholeWord = False
.MatchWildcards = False
.MatchSoundsLike = False
.MatchAllWordForms = False
End With
Selection.Find.Execute Replace:=wdReplaceAll
Selection.Find.ClearFormatting
Selection.Find.Replacement.ClearFormatting
With Selection.Find
.Text = "~~~~"
.Replacement.Text = "^p^p"
.Forward = True
.Wrap = wdFindStop
.Format = False
.MatchCase = False
.MatchWholeWord = False
.MatchWildcards = False
.MatchSoundsLike = False
.MatchAllWordForms = False
End With
Selection.Find.Execute Replace:=wdReplaceAll
With Selection.Find
.Text = " "
.Replacement.Text = " "
.Forward = True
.Wrap = wdFindStop
.Format = False
.MatchCase = False
.MatchWholeWord = False
.MatchWildcards = False
.MatchSoundsLike = False
.MatchAllWordForms = False
End With
Selection.Find.Execute Replace:=wdReplaceAll
Selection.Find.Execute Replace:=wdReplaceAll
Selection.Find.Execute Replace:=wdReplaceAll
End Sub




"Jay Freedman" wrote in message
...
On Wed, 6 Apr 2005 15:56:53 -0400, "Stephen Larivee"
wrote:

I have a long document in Word 2003. I need to do extensive
formating in sections of the file. I selected the text and then
created a macro. I did
my formating moves which involved Find and Replace and said, No, I
did not want to do the rest of the document. I finished and saved
the macro.

Now, I select some other text and then run the macro. But it keeps
doing the entire text, not just the selected text.

What am I doing wrong? How do I get the macro to stay with the
selected text only????


Look at the code of the macro (select the macro in the Tools Macro
Macros dialog and click the Edit button). Somewhere in the mess is
a line that starts with ".Wrap =" followed by a word. If that word is
wdFindContinue, try changing it to wdFindStop.

If that doesn't fix it, post the code in the body of a reply in this
thread.

--
Regards,
Jay Freedman
Microsoft Word MVP FAQ: http://word.mvps.org