View Single Post
  #3   Report Post  
Posted to microsoft.public.word.tables
Al Al is offline
external usenet poster
 
Posts: 57
Default Insert Paragraph Mark in all Table Cells

Thank-you - that is perfect
Much appreciated
Al


"macropod" wrote:

Hi Al,

Try:
Sub InsertCellParas()
Dim TargetRange As Range
Dim oTargCell As Cell

If Selection.Cells.Count = 0 Then
'Quit if no cells in selection
MsgBox "No cells selected", vbCritical
Exit Sub
End If
On Error Resume Next
Set TargetRange = Selection.Range
For Each oTargCell In Selection.Cells
oTargCell.Range.Text = oTargCell.Range.Text
Next oTargCell
TargetRange.Select
End Sub

or, slightly re-worked:

Sub InsertCellParas()
Dim TargetRange As Range
Dim oTargCell As Cell
With Selection
If .Cells.Count = 0 Then
'Quit if no cells in selection
MsgBox "No cells selected", vbCritical
Exit Sub
End If
On Error Resume Next
Set TargetRange = .Range
For Each oTargCell In .Cells
oTargCell.Range.Text = oTargCell.Range.Text
Next
End With
TargetRange.Select
End Sub

Although the code might not seem to be doing anything, "oTargCell.Range.Text = oTargCell.Range.Text" actually causes a para mark to
be inserted.

Cheers

--
macropod
[MVP - Microsoft Word]
-------------------------

"Al" wrote in message ...
I need to have a macro that can insert a Paragraph Mark at the end of every
cell in a table.

I am trying to code this myself from examples but am having no luck

This code offers some hope - I found it from the WordTips site - cycles
through all selected cells but replaces the contents of every cell with
what's in the clipboard, I want to append a Paragraph Mark at the end of the
cell contents.

Sub PasteToCells()
Dim TargetRange As Range
Dim oTargCell As Cell

If Selection.Cells.Count = 0 Then
'Quit if no cells in selection
MsgBox "No cells selected", vbCritical
Exit Sub
End If
On Error Resume Next
Set TargetRange = Selection.Range
For Each oTargCell In Selection.Cells
oTargCell.Range.Paste
Next oTargCell
TargetRange.Select
End Sub

Thank-you
Al