Ureader.com  
Microsoft software help and Community
   home   |   control panel login   |   archive   |  
 
Word
application.errors
conversions
docmanagement
drawing.graphics
formatting.longdocs
international
internet.assistant
mail
mailmerge.fields
menustoolbars
newusers
numbering
oleinterop
pagelayout
printingfonts
setup.networking
spelling.grammar
tables
vba.addins
vba.beginners
vba.customization
vba.general
vba.userforms
web.authoring
word6-7macros
word97vba
  
 
date: Mon, 6 Oct 2008 00:35:00 -0700,    group: microsoft.public.word.vba.general        back       


Trouble deploying a macro that does a find replace   
I'm trying to replace all level 2 text with the formattting  of  0.2 indent 
paragraphing.
It works as a dummy run (ie without pressing macro record) but nothing 
happens when recorded and run as a macro. Help!

Here's the macro



Sub outlinerO()
'
' outlinerO Macro
'
'
    Selection.Find.ClearFormatting
    Selection.Find.Style = ActiveDocument.Styles("Heading 2")
    With Selection.Find.ParagraphFormat
        With .Shading
            .Texture = wdTextureNone
            .ForegroundPatternColor = wdColorBlack
            .BackgroundPatternColor = wdColorBlack
        End With
        .Borders.Shadow = False
    End With
    Selection.Find.Replacement.ClearFormatting
    With Selection.Find.Replacement.ParagraphFormat
        .LeftIndent = CentimetersToPoints(0.2)
        .SpaceBeforeAuto = False
        .SpaceAfterAuto = False
        .CharacterUnitLeftIndent = 0
        .WordWrap = True
    End With
    With Selection.Find.Replacement.ParagraphFormat
        With .Shading
            .Texture = wdTextureNone
            .ForegroundPatternColor = wdColorBlack
            .BackgroundPatternColor = wdColorBlack
        End With
        .Borders.Shadow = False
    End With
    With Selection.Find
        .Text = ""
        .Replacement.Text = ""
        .Forward = True
        .Wrap = wdFindContinue
        .Format = True
        .MatchCase = False
        .MatchWholeWord = False
        .MatchByte = False
        .CorrectHangulEndings = False
        .HanjaPhoneticHangul = False
        .MatchAllWordForms = False
        .MatchSoundsLike = False
        .MatchWildcards = False
        .MatchFuzzy = False
    End With
    Selection.Find.Execute Replace:=wdReplaceAll
End Sub
date: Mon, 6 Oct 2008 00:35:00 -0700   author:   Steve

Re: Trouble deploying a macro that does a find replace   
Why don't you modify the style?

-- 
Hope this helps.

Please reply to the newsgroup unless you wish to avail yourself of my
services on a paid consulting basis.

Doug Robbins - Word MVP

"Steve"  wrote in message 
news:B46E6BC0-15E3-463E-BBE7-B5F96F9F1DFC@microsoft.com...
> I'm trying to replace all level 2 text with the formattting  of  0.2 
> indent
> paragraphing.
> It works as a dummy run (ie without pressing macro record) but nothing
> happens when recorded and run as a macro. Help!
>
> Here's the macro
>
>
>
> Sub outlinerO()
> '
> ' outlinerO Macro
> '
> '
>    Selection.Find.ClearFormatting
>    Selection.Find.Style = ActiveDocument.Styles("Heading 2")
>    With Selection.Find.ParagraphFormat
>        With .Shading
>            .Texture = wdTextureNone
>            .ForegroundPatternColor = wdColorBlack
>            .BackgroundPatternColor = wdColorBlack
>        End With
>        .Borders.Shadow = False
>    End With
>    Selection.Find.Replacement.ClearFormatting
>    With Selection.Find.Replacement.ParagraphFormat
>        .LeftIndent = CentimetersToPoints(0.2)
>        .SpaceBeforeAuto = False
>        .SpaceAfterAuto = False
>        .CharacterUnitLeftIndent = 0
>        .WordWrap = True
>    End With
>    With Selection.Find.Replacement.ParagraphFormat
>        With .Shading
>            .Texture = wdTextureNone
>            .ForegroundPatternColor = wdColorBlack
>            .BackgroundPatternColor = wdColorBlack
>        End With
>        .Borders.Shadow = False
>    End With
>    With Selection.Find
>        .Text = ""
>        .Replacement.Text = ""
>        .Forward = True
>        .Wrap = wdFindContinue
>        .Format = True
>        .MatchCase = False
>        .MatchWholeWord = False
>        .MatchByte = False
>        .CorrectHangulEndings = False
>        .HanjaPhoneticHangul = False
>        .MatchAllWordForms = False
>        .MatchSoundsLike = False
>        .MatchWildcards = False
>        .MatchFuzzy = False
>    End With
>    Selection.Find.Execute Replace:=wdReplaceAll
> End Sub
>
>
>
date: Tue, 7 Oct 2008 16:17:44 +1000   author:   Doug Robbins - Word MVP

Re: Trouble deploying a macro that does a find replace   
Thanks - looks like its time for me to learn about styles.
date: Mon, 6 Oct 2008 23:39:00 -0700   author:   Steve

Google
 
Web ureader.com


    COPYRIGHT 2007, YARDI TECHNOLOGY LIMITED, ALL RIGHT RESERVE  |   contact us