View Single Post
 
Old 12-08-2014, 05:24 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 Word macro:
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 = "^13([a-z]{2}[!_])"
    .Replacement.Text = "\1"
    .Execute Replace:=wdReplaceAll
    .Text = "^13{2,}"
    .Replacement.Text = "^p"
    .Execute Replace:=wdReplaceAll
    .Text = Split(StrFnd, ",")(0) & " "
    .Replacement.Text = ""
    .Execute Replace:=wdReplaceAll
    For i = 1 To UBound(Split(StrFnd, ","))
      .Text = "^13" & Split(StrFnd, ",")(i) & " "
      .Replacement.Text = ","
      .Execute Replace:=wdReplaceAll
    Next
  End With
  .InsertBefore StrFnd & vbCr
End With
Application.ScreenUpdating = True
End Sub
If you save the output as a CSV file, it should load directly into Excel. Note that this assumes there are no commas in the data.

For PC macro installation & usage instructions, see: http://www.gmayor.com/installing_macro.htm.
For Mac macro installation & usage instructions, see: http://word.mvps.org/Mac/InstallMacro.html
__________________
Cheers,
Paul Edstein
[Fmr MS MVP - Word]
Reply With Quote