![]() |
|
#4
|
||||
|
||||
|
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
Have a go at it and see if you can adapt it to your needs. To add the VBA code:
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. |
|
|
Similar Threads
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
Cell formatting
|
Niko | Excel | 5 | 04-23-2009 12:05 AM |
| Table of Contents Formatting | Rick5150 | Word | 1 | 03-16-2009 11:10 AM |
| Re Formatting Columns? | erikjen | Word | 0 | 02-16-2009 12:25 AM |
Word Formatting
|
Peter B. | Word | 5 | 05-10-2006 08:13 AM |
| Different page number formatting. | gerrie | Word | 0 | 04-15-2006 07:31 PM |