#1   Report Post  
Stephen Larivee
 
Posts: n/a
Default macro problems

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????


  #2   Report Post  
Jay Freedman
 
Posts: n/a
Default

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
  #3   Report Post  
Stephen Larivee
 
Posts: n/a
Default

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



  #4   Report Post  
Graham Mayor
 
Posts: n/a
Default

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



  #5   Report Post  
Jay Freedman
 
Posts: n/a
Default

Thanks for stepping in, Graham. You're at least 5 hours ahead of me (are you
back in the UK now, or still in Cyprus?).

I think the section you commented with
'what is this section supposed to be doing?
will change all straight single and double quotes to curly (aka "smart")
quotes, assuming that option is set.

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

Graham Mayor wrote:
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





  #6   Report Post  
Graham Mayor
 
Posts: n/a
Default

I'm currently in the UK - I am off to Ireland next week (so won't be around
for a few days) then back to Cyprus (permanently) on May 17th.

As for the curly quotes I think I would have used autoformat to effect that,
but I have left the original code intact.

--

Graham Mayor - Word MVP

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




Jay Freedman wrote:
Thanks for stepping in, Graham. You're at least 5 hours ahead of me
(are you back in the UK now, or still in Cyprus?).

I think the section you commented with
'what is this section supposed to be doing?
will change all straight single and double quotes to curly (aka
"smart") quotes, assuming that option is set.


Graham Mayor wrote:
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



  #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





Reply
Thread Tools
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
Table in a Form HiDbLevel Tables 12 February 27th 06 12:59 PM
Running document macro from server Intravler New Users 0 March 4th 05 04:33 AM
Save As is not working due to macro security settings Craig Meritz Microsoft Word Help 1 December 16th 04 03:53 AM
2000 to 2002 macro and "Could not open macro storage" Art Farrell Mailmerge 1 December 6th 04 12:40 PM
File Corruption problems Frustrated Page Layout 2 December 3rd 04 09:47 PM


All times are GMT +1. The time now is 09:38 AM.

Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 Microsoft Office Word Forum - WordBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Word"