Home |
Search |
Today's Posts |
#1
|
|||
|
|||
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
|
|||
|
|||
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
|
|||
|
|||
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
|
|||
|
|||
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
|
|||
|
|||
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
|
|||
|
|||
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
|
|||
|
|||
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 | |
|
|
Similar Threads | ||||
Thread | Forum | |||
Table in a Form | Tables | |||
Running document macro from server | New Users | |||
Save As is not working due to macro security settings | Microsoft Word Help | |||
2000 to 2002 macro and "Could not open macro storage" | Mailmerge | |||
File Corruption problems | Page Layout |