View Single Post
 
Old 10-29-2015, 04:33 PM
gmaxey gmaxey is offline Windows 7 32bit Office 2010 (Version 14.0)
Expert
 
Join Date: May 2010
Location: Brasstown, NC
Posts: 1,598
gmaxey is just really nicegmaxey is just really nicegmaxey is just really nicegmaxey is just really nicegmaxey is just really nice
Default

If each line is a separate paragraph then select the text to process and:

Code:
Sub ScratchMacro()
'A basic Word macro coded by Greg Maxey
Dim oRng As Word.Range
Dim oTblRng As Word.Range
Dim oTbl As Table
Dim lngIndex As Long
  Set oRng = Selection.Range
  Set oTblRng = ActiveDocument.Range
  oTblRng.Collapse wdCollapseEnd
  Set oTbl = ActiveDocument.Tables.Add(oTblRng, oRng.Paragraphs.Count, 3)
  For lngIndex = 1 To oRng.Paragraphs.Count
    oTbl.Cell(lngIndex, 1).Range.Text = Trim(oRng.Paragraphs(lngIndex).Range.Words(1))
    If oRng.Paragraphs(lngIndex).Range.Words(2).Font.Italic = True Then
      oTbl.Cell(lngIndex, 2).Range.Text = Trim(oRng.Paragraphs(lngIndex).Range.Words(2))
      oTbl.Cell(lngIndex, 3).Range.Text = Trim(oRng.Paragraphs(lngIndex).Range.Words(3))
    Else
      oTbl.Cell(lngIndex, 3).Range.Text = Trim(oRng.Paragraphs(lngIndex).Range.Words(2))
    End If
  Next lngIndex
lbl_Exit:
  Exit Sub
End Sub
__________________
Greg Maxey
Please visit my web site at http://www.gregmaxey.com/
Reply With Quote