![]() |
|
#2
|
||||
|
||||
|
You could use a macro like the following. Just don't expect the processing to be instantaneous in a 1430-page document!
Code:
Sub ParseDoc()
Application.ScreenUpdating = False
Dim i As Long, RngSrc As Range, RngTgt As Range
With ActiveDocument.Range
For i = .Sentences.Count To 1 Step -1
Set RngSrc = .Sentences(i)
With RngSrc
Do While .Characters.Last Like "[ " & vbCr & Chr(160) & "]"
.End = .End - 1
If .Start = .End Then Exit Do
Loop
End With
If Len(RngSrc.Text) > 1 Then
Set RngTgt = RngSrc.Duplicate
With RngTgt
.InsertAfter Chr(11)
.Collapse wdCollapseEnd
.FormattedText = RngSrc.FormattedText
.InsertBefore "("
.Characters.Last.InsertBefore ")("
.InsertAfter ")" & Chr(11)
With .Find
.ClearFormatting
.Replacement.ClearFormatting
.Text = "[ ]{1,}"
.Replacement.Text = ") ("
.Forward = True
.Wrap = wdFindStop
.Format = False
.MatchWildcards = True
.Execute Replace:=wdReplaceAll
End With
End With
End If
Next
With .Find
.ClearFormatting
.Replacement.ClearFormatting
.Forward = True
.Wrap = wdFindContinue
.Format = False
.MatchWildcards = True
.Text = "^l^13"
.Replacement.Text = "^p"
.Execute Replace:=wdReplaceAll
.Text = "^l "
.Replacement.Text = "^l"
.Execute Replace:=wdReplaceAll
End With
End With
Application.ScreenUpdating = True
End Sub
__________________
Cheers, Paul Edstein [Fmr MS MVP - Word] |
| Tags |
| macro, parentheses |
|
|
Similar Threads
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| Insert a pdf file into a word document | raistlin | Word | 2 | 01-08-2014 01:42 PM |
Word insert only 1st page of multi-paged PDF file
|
Evgeniy | Word | 1 | 02-04-2012 01:36 PM |
Insert-Text from File in Word Ribbon?
|
tatihulot | Word | 2 | 10-12-2011 04:40 AM |
Parentheses Changing on Document
|
Subject1157 | Word | 2 | 06-16-2011 08:46 PM |
| How to insert a .mov file in Word Document | Jai25 | Word | 0 | 02-11-2010 04:40 PM |