Results 1 to 2 of 2
  1. #1
    Bronze Lounger
    Join Date
    Jun 2001
    Location
    New York, New York, Lebanon
    Posts
    1,449
    Thanks
    1
    Thanked 1 Time in 1 Post

    Auto-Format Code (97 and >)

    <img src=/S/hello.gif border=0 alt=hello width=25 height=29> Loungers

    Can anyone tell me what the code behind the Auto Format command (Format | Auto Format...) looks like?

    I some times use this command and it works, but other times, it just thinks what is best to do and does it.

    I sure would like to talk to the MS-Word person who wrote that code <img src=/S/argue.gif border=0 alt=argue width=50 height=25> !!!

    One of the questions I would like to ask is why there is no Re-Do on this command?

    Maybe I can write my own code and have it do exactly what I want it to do. <img src=/S/bullseye.gif border=0 alt=bullseye width=45 height=15>

    Or maybe you gurus can tell me if there is a better option for cleaning e-mails <img src=/S/clapping.gif border=0 alt=clapping width=19 height=23>

    Thanks

    Wassim
    <img src=/S/compute.gif border=0 alt=compute width=40 height=20> in the <img src=/S/bagged.gif border=0 alt=bagged width=22 height=22>

  2. #2
    Uranium Lounger
    Join Date
    Dec 2000
    Location
    Los Angeles Area, California, USA
    Posts
    7,453
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Auto-Format Code (97 and >)

    You can adjust what AutoFormat does by going to Tools/AutoCorrect.../AutoFormat tab & selecting just the options that you want AutoFormat to work on. I don't use it for emails except where I have numbered lists. I sometimes use the following code (which I would redo to reformat with a body text style, rather than double paragraph marks, if I wanted to redo my documents.<pre>Sub EmailClean()
    '
    ' EmailClean Macro
    ' operates on selected text
    ' Macro created 6/12/01 by Phil Rabichow
    '
    Application.ScreenUpdating = False
    Selection.Range.Style = ActiveDocument.Styles(wdStyleNormal)
    Selection.Find.ClearFormatting
    Selection.Find.Replacement.ClearFormatting

    ' Replace line break with paragraph mark
    With Selection.Find
    .Text = "^l"
    .Replacement.Text = "^p"
    .Forward = True
    .Wrap = wdFindStop
    .Format = False
    .MatchCase = False
    .MatchWholeWord = False
    .MatchAllWordForms = False
    .MatchSoundsLike = False
    .MatchWildcards = False
    End With
    Selection.Find.Execute Replace:=wdReplaceAll

    ' Remove white space at the beginning of lines
    With Selection.Find
    .Text = "^p^w"
    .Replacement.Text = "^p"
    End With
    Selection.Find.Execute Replace:=wdReplaceAll

    ' Remove spaces before paragraph marks
    With Selection.Find
    .Text = " {1,}^013"
    .Replacement.Text = "^p"
    .MatchWildcards = True
    End With
    Selection.Find.Execute Replace:=wdReplaceAll

    ' This prevents extra paragraph marks at the end of the selection
    Selection.MoveLeft Unit:=wdCharacter, Count:=1, Extend:=wdExtend

    ' Removes spaces in first line
    With Selection.Find
    .Text = " {3,}"
    .Replacement.Text = ""
    End With
    Selection.Find.Execute Replace:=wdReplaceAll

    ' Replace end of line paragraph marks with a space
    With Selection.Find
    .Text = "^p^p"
    .Replacement.Text = "%$%"
    .MatchWildcards = False
    End With
    Selection.Find.Execute Replace:=wdReplaceAll
    ' Since this causes 3 paragraph marks to have a space,
    With Selection.Find
    .Text = "^p"
    .Replacement.Text = " "
    End With
    Selection.Find.Execute Replace:=wdReplaceAll
    With Selection.Find
    .Text = "%$%"
    .Replacement.Text = "^p"
    End With
    Selection.Find.Execute Replace:=wdReplaceAll

    ' we added this to remove the space paragraph
    With Selection.Find
    .Text = "^p "
    .Replacement.Text = "^p"
    End With
    Selection.Find.Execute Replace:=wdReplaceAll
    ' This puts 2 spaces between sentences
    With Selection.Find
    .Text = ". {1,}"
    .Replacement.Text = ". "
    .MatchWildcards = True
    End With
    Selection.Find.Execute Replace:=wdReplaceAll
    Selection.Find.ClearFormatting
    Selection.Find.Replacement.ClearFormatting
    With Selection.Find
    .Text = "? {1,}"
    .Replacement.Text = "? "
    End With
    Selection.Find.Execute Replace:=wdReplaceAll
    With Selection.Find
    .Text = "! {1,}"
    .Replacement.Text = "! "
    End With
    Selection.Find.Execute Replace:=wdReplaceAll
    ' we'll see how it works without this
    ' Selection.Find.ClearFormatting
    ' Selection.Find.Replacement.ClearFormatting
    ' With Selection.Find
    ' .Text = "^w^p"
    ' .Replacement.Text = "^p"
    ' .MatchWildcards = False
    ' End With
    'Selection.Find.Execute Replace:=wdReplaceAll
    ' Selection.Find.ClearFormatting
    ' Selection.Find.Replacement.ClearFormatting
    With Selection.Find
    .Text = "^p"
    .Replacement.Text = "^p^p"
    .MatchWildcards = False
    End With
    Selection.Find.Execute Replace:=wdReplaceAll
    ' With Selection.Find
    ' .Text = " {1,}^013"
    ' .Replacement.Text = "^p"
    ' .MatchWildcards = True
    ' End With
    'Selection.Find.Execute Replace:=wdReplaceAll
    Selection.MoveRight Unit:=wdCharacter, Count:=1, Extend:=wdMove
    Application.ScreenUpdating = True
    End Sub</pre>

    Cheers,

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •