View Single Post
 
Old 07-23-2014, 12:21 PM
gmaxey gmaxey is offline Windows 7 32bit Office 2010 (Version 14.0)
Expert
 
Join Date: May 2010
Location: Brasstown, NC
Posts: 1,617
gmaxey is just really nicegmaxey is just really nicegmaxey is just really nicegmaxey is just really nicegmaxey is just really nice
Default

Code:
Sub ScratchMacro()
'A basic Word macro coded by Greg Maxey
Dim oRow As Row
  Set oRow = ActiveDocument.Tables(2).Rows.Add
  'You need to strip the end of cell marker.  This is a little cumbersome inline:
  oRow.Cells(1).Range.Text = Left(ActiveDocument.Tables(1).Rows(1).Range.Cells(1).Range.Text, _
                             Len(ActiveDocument.Tables(1).Rows(1).Range.Cells(1).Range.Text) - 2)
  'So use a function instead
  oRow.Cells(1).Range.Text = CellContent(ActiveDocument.Tables(1).Rows(1).Range.Cells(1))
End Sub
 Function CellContent(oCell As Cell) As String
Dim oRng As Word.Range
   Set oRng = oCell.Range
   oRng.End = oRng.End - 1
   CellContent = oRng.Text
End Function
__________________
Greg Maxey
Please visit my web site at http://www.gregmaxey.com/
Reply With Quote