Results 1 to 3 of 3
  1. #1
    3 Star Lounger
    Join Date
    Jan 2001
    Location
    Sunrise, Florida
    Posts
    324
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Hard (non-breaking) space (Word 2K3)

    I would like to have a macro that would 1) automatically search every paragraph in a document, 2) look for the last "breaking space" in the paragraph, and 3) replace it with a hard (non-breaking) space. I have miserably failed in my attempts, mostly because I can't seem to make mine stop at the end of the document. Any guidance will be appreciated. Thanks!

  2. #2
    Plutonium Lounger
    Join Date
    Mar 2002
    Posts
    84,353
    Thanks
    0
    Thanked 29 Times in 29 Posts

    Re: Hard (non-breaking) space (Word 2K3)

    Try this:

    Sub ReplaceLastSpaceInPara()
    Dim par As Paragraph
    Dim rng As Range
    For Each par In ActiveDocument.Paragraphs
    Set rng = par.Range
    With rng.Find
    .ClearFormatting
    .Replacement.ClearFormatting
    .MatchWholeWord = False
    .MatchWildcards = False
    .Forward = False
    .Text = " "
    .Replacement.Text = "^s"
    .Execute Replace:=wdReplaceOne
    End With
    Next par
    End Sub

  3. #3
    3 Star Lounger
    Join Date
    Jan 2001
    Location
    Sunrise, Florida
    Posts
    324
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Hard (non-breaking) space (Word 2K3)

    What can I say, Hans! It works like a charm and, like always, you guys deliver. Thanks you very much!!!

Posting Permissions

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