View Single Post
 
Old 12-10-2014, 02:03 PM
macropod's Avatar
macropod macropod is offline Windows 7 64bit Office 2010 32bit
Administrator
 
Join Date: Dec 2010
Location: Canberra, Australia
Posts: 22,367
macropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond repute
Default

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]
Reply With Quote