locked
Macro 2 RRS feed

  • Question

  • mark 


    • Edited by ALI74 Tuesday, December 18, 2012 7:56 AM
    Monday, December 17, 2012 3:10 PM

Answers

  • The following macro should do what you ask:

    Sub TwoSpaces()
        With ActiveDocument.Content.Find
            .ClearFormatting
            .Replacement.ClearFormatting
            .MatchWildcards = True
            .Execute FindText:="([.,\?\!]) {1,}", ReplaceWith:="\1", Replace:=wdReplaceAll
            .Execute FindText:="([.,\?\!])", ReplaceWith:="\1  ", Replace:=wdReplaceAll
        End With
    End Sub

    But this will also insert two spaces after a dot, comma or exclamation mark followed by a paragraph break, line break, page break or section break...

    Regards, Hans Vogelaar

    Monday, December 17, 2012 3:48 PM

All replies

  • The following macro should do what you ask:

    Sub TwoSpaces()
        With ActiveDocument.Content.Find
            .ClearFormatting
            .Replacement.ClearFormatting
            .MatchWildcards = True
            .Execute FindText:="([.,\?\!]) {1,}", ReplaceWith:="\1", Replace:=wdReplaceAll
            .Execute FindText:="([.,\?\!])", ReplaceWith:="\1  ", Replace:=wdReplaceAll
        End With
    End Sub

    But this will also insert two spaces after a dot, comma or exclamation mark followed by a paragraph break, line break, page break or section break...

    Regards, Hans Vogelaar

    Monday, December 17, 2012 3:48 PM
  • mark 



    Ali,

    Please reinstate your first post's original content. Without it you have destroyed the context for the rest of the thread.


    Cheers
    Paul Edstein
    [MS MVP - Word]

    Wednesday, December 19, 2012 11:33 AM
  • Please stop modifying and deleting your original posts!


    Word MVP

    Wednesday, December 19, 2012 7:39 PM
  • I,

    I am retyping the question... give me some.. as the the net is going dead slow... will retain all question in all the threads i have modified.


    ALI

    Thursday, December 20, 2012 7:45 AM