|
From: Karen Sigel on 25 Jun 2008 12:49 In Word 2003, I've written a macro to change specific parts of the text in a document to Dark Red (RGB 128,0,0) with a Find/Replace. I tested and created the Find/Replace first, then duplicated the actions to record the macro. When I do the F/R manually, it works just fine; it also works while I'm recording it. After I finish the recording and run the macro, however, it does everything EXCEPT change the color. What am I doing wrong and how can I fix it? Here's the text of my macro: ' FixResumeProjectName Macro ' Macro recorded 6/25/2008 by klsigel ' Selection.Find.ClearFormatting Selection.Find.Replacement.ClearFormatting With Selection.Find .Text = "---*---" .Replacement.Text = "^&" .Forward = True .Wrap = wdFindContinue .Format = True .MatchCase = False .MatchWholeWord = False .MatchAllWordForms = False .MatchSoundsLike = False .MatchWildcards = True End With Selection.Find.Execute Replace:=wdReplaceAll Selection.Find.ClearFormatting Selection.Find.Replacement.ClearFormatting With Selection.Find .Text = "---" .Replacement.Text = "" .Forward = True .Wrap = wdFindContinue .Format = False .MatchCase = False .MatchWholeWord = False .MatchAllWordForms = False .MatchSoundsLike = False .MatchWildcards = True End With Selection.Find.Execute Replace:=wdReplaceAll End Sub Thanks- Karen
From: Jay Freedman on 25 Jun 2008 13:58 A bug in the recorder causes it to omit the formatting settings (any formatting, bold or italic or color, etc.), so your recorded macro doesn't contain any reference to the color you asked for. Look at the "Fixing broken Replace macros" section of http://www.word.mvps.org/FAQs/MacrosVBA/ModifyRecordedMacro.htm. The statement you need to add (to the With Selection.Find group of each of the two replacements) is .Font.Color = wdColorDarkRed -- Regards, Jay Freedman Microsoft Word MVP FAQ: http://word.mvps.org Email cannot be acknowledged; please post all follow-ups to the newsgroup so all may benefit. Karen Sigel wrote: > In Word 2003, I've written a macro to change specific parts of the > text in a document to Dark Red (RGB 128,0,0) with a Find/Replace. I > tested and created the Find/Replace first, then duplicated the > actions to record the macro. When I do the F/R manually, it works > just fine; it also works while I'm recording it. After I finish the > recording and run the macro, however, it does everything EXCEPT > change the color. What am I doing wrong and how can I fix it? > > Here's the text of my macro: > > ' FixResumeProjectName Macro > ' Macro recorded 6/25/2008 by klsigel > ' > Selection.Find.ClearFormatting > Selection.Find.Replacement.ClearFormatting > With Selection.Find > .Text = "---*---" > .Replacement.Text = "^&" > .Forward = True > .Wrap = wdFindContinue > .Format = True > .MatchCase = False > .MatchWholeWord = False > .MatchAllWordForms = False > .MatchSoundsLike = False > .MatchWildcards = True > End With > Selection.Find.Execute Replace:=wdReplaceAll > Selection.Find.ClearFormatting > Selection.Find.Replacement.ClearFormatting > With Selection.Find > .Text = "---" > .Replacement.Text = "" > .Forward = True > .Wrap = wdFindContinue > .Format = False > .MatchCase = False > .MatchWholeWord = False > .MatchAllWordForms = False > .MatchSoundsLike = False > .MatchWildcards = True > End With > Selection.Find.Execute Replace:=wdReplaceAll > End Sub > > Thanks- > Karen
From: Karen Sigel on 25 Jun 2008 15:07 OK, I'm totally confused now. I've copied your statement to where I thought it should go based on your reply and your article, and it still doesn't work. This is what I have at the moment: Sub DarkRedResumeText() ' ' DarkRedResumeText Macro ' Macro recorded 6/25/2008 by klsigel ' Selection.Find.ClearFormatting Selection.Find.Replacement.ClearFormatting With Selection.Find .Text = "---*---" .Replacement.Text = "^&" .Font.Color = wdColorDarkRed .Forward = True .Wrap = wdFindContinue .Format = True .MatchCase = False .MatchWholeWord = False .MatchAllWordForms = False .MatchSoundsLike = False .MatchWildcards = True End With Selection.Find.Execute Replace:=wdReplaceAll Selection.Find.ClearFormatting Selection.Find.Replacement.ClearFormatting With Selection.Find .Text = "---" .Replacement.Text = "" .Forward = True .Wrap = wdFindContinue .Format = False .MatchCase = False .MatchWholeWord = False .MatchAllWordForms = False .MatchSoundsLike = False .MatchWildcards = True End With Selection.Find.Execute Replace:=wdReplaceAll End Sub Thanks for your help- Karen "Jay Freedman" wrote: > A bug in the recorder causes it to omit the formatting settings (any > formatting, bold or italic or color, etc.), so your recorded macro doesn't > contain any reference to the color you asked for. > > Look at the "Fixing broken Replace macros" section of > http://www.word.mvps.org/FAQs/MacrosVBA/ModifyRecordedMacro.htm. > > The statement you need to add (to the With Selection.Find group of each of > the two replacements) is > > .Font.Color = wdColorDarkRed > > -- > Regards, > Jay Freedman > Microsoft Word MVP FAQ: http://word.mvps.org > Email cannot be acknowledged; please post all follow-ups to the newsgroup so > all may benefit. > > Karen Sigel wrote: > > In Word 2003, I've written a macro to change specific parts of the > > text in a document to Dark Red (RGB 128,0,0) with a Find/Replace. I > > tested and created the Find/Replace first, then duplicated the > > actions to record the macro. When I do the F/R manually, it works > > just fine; it also works while I'm recording it. After I finish the > > recording and run the macro, however, it does everything EXCEPT > > change the color. What am I doing wrong and how can I fix it? > > > > Here's the text of my macro: > > > > ' FixResumeProjectName Macro > > ' Macro recorded 6/25/2008 by klsigel > > ' > > Selection.Find.ClearFormatting > > Selection.Find.Replacement.ClearFormatting > > With Selection.Find > > .Text = "---*---" > > .Replacement.Text = "^&" > > .Forward = True > > .Wrap = wdFindContinue > > .Format = True > > .MatchCase = False > > .MatchWholeWord = False > > .MatchAllWordForms = False > > .MatchSoundsLike = False > > .MatchWildcards = True > > End With > > Selection.Find.Execute Replace:=wdReplaceAll > > Selection.Find.ClearFormatting > > Selection.Find.Replacement.ClearFormatting > > With Selection.Find > > .Text = "---" > > .Replacement.Text = "" > > .Forward = True > > .Wrap = wdFindContinue > > .Format = False > > .MatchCase = False > > .MatchWholeWord = False > > .MatchAllWordForms = False > > .MatchSoundsLike = False > > .MatchWildcards = True > > End With > > Selection.Find.Execute Replace:=wdReplaceAll > > End Sub > > > > Thanks- > > Karen > > >
From: Jonathan West on 25 Jun 2008 15:13 Take a look at this article What do I do with macros sent to me by other newsgroup readers to help me out? http://www.word.mvps.org/FAQs/MacrosVBA/CreateAMacro.htm -- Regards Jonathan West - Word MVP www.intelligentdocuments.co.uk Please reply to the newsgroup "Karen Sigel" <KarenSigel(a)discussions.microsoft.com> wrote in message news:9EFF0BD8-0358-4ABB-BDC7-E864252F4C31(a)microsoft.com... > OK, I'm totally confused now. I've copied your statement to where I > thought > it should go based on your reply and your article, and it still doesn't > work. > This is what I have at the moment: > > Sub DarkRedResumeText() > ' > ' DarkRedResumeText Macro > ' Macro recorded 6/25/2008 by klsigel > ' > Selection.Find.ClearFormatting > Selection.Find.Replacement.ClearFormatting > With Selection.Find > .Text = "---*---" > .Replacement.Text = "^&" > .Font.Color = wdColorDarkRed > .Forward = True > .Wrap = wdFindContinue > .Format = True > .MatchCase = False > .MatchWholeWord = False > .MatchAllWordForms = False > .MatchSoundsLike = False > .MatchWildcards = True > End With > Selection.Find.Execute Replace:=wdReplaceAll > Selection.Find.ClearFormatting > Selection.Find.Replacement.ClearFormatting > With Selection.Find > .Text = "---" > .Replacement.Text = "" > .Forward = True > .Wrap = wdFindContinue > .Format = False > .MatchCase = False > .MatchWholeWord = False > .MatchAllWordForms = False > .MatchSoundsLike = False > .MatchWildcards = True > End With > Selection.Find.Execute Replace:=wdReplaceAll > End Sub > > Thanks for your help- > Karen > > "Jay Freedman" wrote: > >> A bug in the recorder causes it to omit the formatting settings (any >> formatting, bold or italic or color, etc.), so your recorded macro >> doesn't >> contain any reference to the color you asked for. >> >> Look at the "Fixing broken Replace macros" section of >> http://www.word.mvps.org/FAQs/MacrosVBA/ModifyRecordedMacro.htm. >> >> The statement you need to add (to the With Selection.Find group of each >> of >> the two replacements) is >> >> .Font.Color = wdColorDarkRed >> >> -- >> Regards, >> Jay Freedman >> Microsoft Word MVP FAQ: http://word.mvps.org >> Email cannot be acknowledged; please post all follow-ups to the newsgroup >> so >> all may benefit. >> >> Karen Sigel wrote: >> > In Word 2003, I've written a macro to change specific parts of the >> > text in a document to Dark Red (RGB 128,0,0) with a Find/Replace. I >> > tested and created the Find/Replace first, then duplicated the >> > actions to record the macro. When I do the F/R manually, it works >> > just fine; it also works while I'm recording it. After I finish the >> > recording and run the macro, however, it does everything EXCEPT >> > change the color. What am I doing wrong and how can I fix it? >> > >> > Here's the text of my macro: >> > >> > ' FixResumeProjectName Macro >> > ' Macro recorded 6/25/2008 by klsigel >> > ' >> > Selection.Find.ClearFormatting >> > Selection.Find.Replacement.ClearFormatting >> > With Selection.Find >> > .Text = "---*---" >> > .Replacement.Text = "^&" >> > .Forward = True >> > .Wrap = wdFindContinue >> > .Format = True >> > .MatchCase = False >> > .MatchWholeWord = False >> > .MatchAllWordForms = False >> > .MatchSoundsLike = False >> > .MatchWildcards = True >> > End With >> > Selection.Find.Execute Replace:=wdReplaceAll >> > Selection.Find.ClearFormatting >> > Selection.Find.Replacement.ClearFormatting >> > With Selection.Find >> > .Text = "---" >> > .Replacement.Text = "" >> > .Forward = True >> > .Wrap = wdFindContinue >> > .Format = False >> > .MatchCase = False >> > .MatchWholeWord = False >> > .MatchAllWordForms = False >> > .MatchSoundsLike = False >> > .MatchWildcards = True >> > End With >> > Selection.Find.Execute Replace:=wdReplaceAll >> > End Sub >> > >> > Thanks- >> > Karen >> >> >>
From: Karen Sigel on 25 Jun 2008 15:34
Jonathan- Thank you. I read the article, but my issue isn't what to do with a whole macro sent to me by someone else; the macro is mine. It's supposed to find all the text between --- and ---, replace it with itself, and change it to font color dark red. It does everything except change the font color. What I need to know is, where do I place the statement sent by Jay (.Font.Color = wdColorDarkRed) into my macro. I've placed it where I think it should go, but it's not doing what I want, which is to change the Find What Text (^&) to Dark Red. Karen "Jonathan West" wrote: > Take a look at this article > > What do I do with macros sent to me by other newsgroup readers to help me > out? > http://www.word.mvps.org/FAQs/MacrosVBA/CreateAMacro.htm > > > -- > Regards > Jonathan West - Word MVP > www.intelligentdocuments.co.uk > Please reply to the newsgroup > > > > "Karen Sigel" <KarenSigel(a)discussions.microsoft.com> wrote in message > news:9EFF0BD8-0358-4ABB-BDC7-E864252F4C31(a)microsoft.com... > > OK, I'm totally confused now. I've copied your statement to where I > > thought > > it should go based on your reply and your article, and it still doesn't > > work. > > This is what I have at the moment: > > > > Sub DarkRedResumeText() > > ' > > ' DarkRedResumeText Macro > > ' Macro recorded 6/25/2008 by klsigel > > ' > > Selection.Find.ClearFormatting > > Selection.Find.Replacement.ClearFormatting > > With Selection.Find > > .Text = "---*---" > > .Replacement.Text = "^&" > > .Font.Color = wdColorDarkRed > > .Forward = True > > .Wrap = wdFindContinue > > .Format = True > > .MatchCase = False > > .MatchWholeWord = False > > .MatchAllWordForms = False > > .MatchSoundsLike = False > > .MatchWildcards = True > > End With > > Selection.Find.Execute Replace:=wdReplaceAll > > Selection.Find.ClearFormatting > > Selection.Find.Replacement.ClearFormatting > > With Selection.Find > > .Text = "---" > > .Replacement.Text = "" > > .Forward = True > > .Wrap = wdFindContinue > > .Format = False > > .MatchCase = False > > .MatchWholeWord = False > > .MatchAllWordForms = False > > .MatchSoundsLike = False > > .MatchWildcards = True > > End With > > Selection.Find.Execute Replace:=wdReplaceAll > > End Sub > > > > Thanks for your help- > > Karen > > > > "Jay Freedman" wrote: > > > >> A bug in the recorder causes it to omit the formatting settings (any > >> formatting, bold or italic or color, etc.), so your recorded macro > >> doesn't > >> contain any reference to the color you asked for. > >> > >> Look at the "Fixing broken Replace macros" section of > >> http://www.word.mvps.org/FAQs/MacrosVBA/ModifyRecordedMacro.htm. > >> > >> The statement you need to add (to the With Selection.Find group of each > >> of > >> the two replacements) is > >> > >> .Font.Color = wdColorDarkRed > >> > >> -- > >> Regards, > >> Jay Freedman > >> Microsoft Word MVP FAQ: http://word.mvps.org > >> Email cannot be acknowledged; please post all follow-ups to the newsgroup > >> so > >> all may benefit. > >> > >> Karen Sigel wrote: > >> > In Word 2003, I've written a macro to change specific parts of the > >> > text in a document to Dark Red (RGB 128,0,0) with a Find/Replace. I > >> > tested and created the Find/Replace first, then duplicated the > >> > actions to record the macro. When I do the F/R manually, it works > >> > just fine; it also works while I'm recording it. After I finish the > >> > recording and run the macro, however, it does everything EXCEPT > >> > change the color. What am I doing wrong and how can I fix it? > >> > > >> > Here's the text of my macro: > >> > > >> > ' FixResumeProjectName Macro > >> > ' Macro recorded 6/25/2008 by klsigel > >> > ' > >> > Selection.Find.ClearFormatting > >> > Selection.Find.Replacement.ClearFormatting > >> > With Selection.Find > >> > .Text = "---*---" > >> > .Replacement.Text = "^&" > >> > .Forward = True > >> > .Wrap = wdFindContinue > >> > .Format = True > >> > .MatchCase = False > >> > .MatchWholeWord = False > >> > .MatchAllWordForms = False > >> > .MatchSoundsLike = False > >> > .MatchWildcards = True > >> > End With > >> > Selection.Find.Execute Replace:=wdReplaceAll > >> > Selection.Find.ClearFormatting > >> > Selection.Find.Replacement.ClearFormatting > >> > With Selection.Find > >> > .Text = "---" > >> > .Replacement.Text = "" > >> > .Forward = True > >> > .Wrap = wdFindContinue > >> > .Format = False > >> > .MatchCase = False > >> > .MatchWholeWord = False > >> > .MatchAllWordForms = False > >> > .MatchSoundsLike = False > >> > .MatchWildcards = True > >> > End With > >> > Selection.Find.Execute Replace:=wdReplaceAll > >> > End Sub > >> > > >> > Thanks- > >> > Karen > >> > >> > >> > > > |