I would say the quickest, and probably most accurate, way would be to run through the document and add your [**] symbols yourself, then just Find and Replace the paragraph markers. - I know that this isn't the ideal solution, but having done the same thing that you are aiming to do, and having done it a million and one times, I just found it the most accurate!
It
IS possible to write some VBA code to do what you want - BUT, it WON'T be anywhere near as accurate. For example, you asked about sorting it by paragraph - the problem is, your document has a paragraph marker at the end of every line, oops!
How about adapting your search string and turning it into a VBA code string:
Code:
Sub Find_and_Replace_Loop()
' Code String Written by Bird - 2009
' This macro will find and replace
' a) all full stops, question marks and exclamation marks followed by double paragraph markers
' b) 2 paragraph markers together - this is repeated in case there are 3 or four together
' c) all single paragraph markers, into spaces
' d) finally putting paragraph markers back.
Selection.Find.ClearFormatting
With Selection.Find
.Text = ".^p^p"
.Replacement.Text = ".**"
.Forward = True
.Wrap = wdFindContinue
.Format = False
.MatchCase = False
.MatchWholeWord = False
.MatchWildcards = False
.MatchSoundsLike = False
.MatchAllWordForms = False
End With
With Selection.Find
.Text = "?^p^p"
.Replacement.Text = "?**"
.Forward = True
.Wrap = wdFindContinue
.Format = False
.MatchCase = False
.MatchWholeWord = False
.MatchWildcards = False
.MatchSoundsLike = False
.MatchAllWordForms = False
End With
With Selection.Find
.Text = "!^p^p"
.Replacement.Text = "!**"
.Forward = True
.Wrap = wdFindContinue
.Format = False
.MatchCase = False
.MatchWholeWord = False
.MatchWildcards = False
.MatchSoundsLike = False
.MatchAllWordForms = False
End With
With Selection.Find
.Text = "^p^p"
.Replacement.Text = "^p"
.Forward = True
.Wrap = wdFindContinue
.Format = False
.MatchCase = False
.MatchWholeWord = False
.MatchWildcards = False
.MatchSoundsLike = False
.MatchAllWordForms = False
End With
With Selection.Find
.Text = "^p^p"
.Replacement.Text = "^p"
.Forward = True
.Wrap = wdFindContinue
.Format = False
.MatchCase = False
.MatchWholeWord = False
.MatchWildcards = False
.MatchSoundsLike = False
.MatchAllWordForms = False
End With
With Selection.Find
.Text = "^p^p"
.Replacement.Text = "^p"
.Forward = True
.Wrap = wdFindContinue
.Format = False
.MatchCase = False
.MatchWholeWord = False
.MatchWildcards = False
.MatchSoundsLike = False
.MatchAllWordForms = False
End With
With Selection.Find
.Text = "^p"
.Replacement.Text = " "
.Forward = True
.Wrap = wdFindContinue
.Format = False
.MatchCase = False
.MatchWholeWord = False
.MatchWildcards = False
.MatchSoundsLike = False
.MatchAllWordForms = False
End With
With Selection.Find
.Text = "**"
.Replacement.Text = "^p"
.Forward = True
.Wrap = wdFindContinue
.Format = False
.MatchCase = False
.MatchWholeWord = False
.MatchWildcards = False
.MatchSoundsLike = False
.MatchAllWordForms = False
End With
Loop
End Sub
This is just an example of what you can do. I have expanded the double paragraph marker string to start with [. ! ?] as these would be the markers at the end of a complete sentence in a paragraph.
Have a go at it and see if you can adapt it to your needs.
To add the VBA code:
- Open Word
- Use Alt+F11 to open your VBA window
- In the Left hand 'tree' window look for Normal and open the Modules
- If there is no Module, use the Insert menu to add one
- Once you have a Module, double-click it to open
- Copy and Paste the above code
By putting this in
Normal you are able to use this macro in any document.
To run it - (2003) Tools > Macro > Macros (or Alt+F8)
(2007) View > Macros > View Macros (or Alt+F8)
Have fun with the code - play around with it to suit your needs.