![]() |
|
#7
|
||||
|
||||
|
OK, try the following version of the macro. You don't even need to create the output document beforehand - the macro does that for itself.
Code:
Sub Demo()
Application.ScreenUpdating = False
Dim StrTxt As String
StrTxt = ""
With ActiveDocument.Range
With .Find
.ClearFormatting
.Replacement.ClearFormatting
.Text = "FirstN*[0-9]{3}[\+\-][0-9]{3}[\+\-][0-9]{4}*LastN\=*>?"
.Replacement.Text = ""
.Forward = True
.Wrap = wdFindStop
.Format = False
.MatchWildcards = True
.Execute
End With
Do While .Find.Found
If InStr(StrTxt, .Duplicate.Text) = 0 Then StrTxt = StrTxt & .Duplicate.Text & "|"
.Collapse wdCollapseEnd
.Find.Execute
Loop
End With
Documents.Add
With ActiveDocument.Range
.InsertAfter Replace(StrTxt, "|", vbCr)
.Characters.Last.Delete
End With
Application.ScreenUpdating = True
End Sub
__________________
Cheers, Paul Edstein [Fmr MS MVP - Word] |
|
|
Similar Threads
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
Extract Video from .ppsx file
|
designer | PowerPoint | 1 | 10-14-2011 08:00 AM |
Phone number formatting
|
Mark Micallef | Outlook | 1 | 08-04-2010 02:38 PM |
| Can I Extract a Page from Word and Make a New DOCX File? | tatihulot | Word | 1 | 06-20-2010 11:38 PM |
| in WORD, how do i type a 9-digit phone number "xxxxxxxxx" and have it automatically.. | jay8962 | Word | 0 | 04-08-2010 11:08 AM |
| automatically extract footnotes into new file and apply character format to footnote | hrdwa | Word | 0 | 02-27-2010 03:16 AM |