![]() |
|
|
|
#1
|
||||
|
||||
|
Try the following version of the code: Code:
Sub Demo()
Application.ScreenUpdating = False
Dim StrFnd As String, i As Long
StrFnd = "at_case_id,ca_case_ref,at_created_dt,at_audit_type,at_audit_note,at_user_id"
With ActiveDocument.Range
With .Find
.ClearFormatting
.Replacement.ClearFormatting
.Format = False
.Forward = True
.Wrap = wdFindContinue
.MatchWildcards = True
.Text = vbCr
.Replacement.Text = "^p"
.Execute Replace:=wdReplaceAll
.Text = "^13([ ]{15})"
.Replacement.Text = ""
.Execute Replace:=wdReplaceAll
.Text = "^13{2,}"
.Replacement.Text = "^p"
.Execute Replace:=wdReplaceAll
.Text = Split(StrFnd, ",")(0) & "[ ]{1,}"
.Replacement.Text = ""
.Execute Replace:=wdReplaceAll
For i = 1 To UBound(Split(StrFnd, ","))
.Text = "?" & Split(StrFnd, ",")(i) & "[ ]{1,}"
.Replacement.Text = ","
.Execute Replace:=wdReplaceAll
Next
End With
.InsertBefore StrFnd & vbCr
With .Find
.Text = "^13{2,}"
.Replacement.Text = "^p"
.Execute Replace:=wdReplaceAll
End With
End With
Application.ScreenUpdating = True
End Sub
__________________
Cheers, Paul Edstein [Fmr MS MVP - Word] |
|
|
|
Similar Threads
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
Find/Replace Wildcard Needed-Bold & Highlight
|
rsrasc | Word VBA | 3 | 11-11-2014 03:55 PM |
New Find/Replace Wildcard Needed
|
rsrasc | Word VBA | 2 | 11-11-2014 09:46 AM |
Find/Replace Wildcard Needed
|
rsrasc | Word VBA | 4 | 11-11-2014 08:28 AM |
| Advanced search and replace for bullet points | TishyMouse | Word | 5 | 02-17-2012 06:32 AM |
Advanced find and replace
|
anno1404 | Word | 1 | 10-21-2010 03:58 AM |