Reply
 
Thread Tools Display Modes
  #1   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

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



  #2   Report Post  
Posted to microsoft.public.word.tables
macropod macropod is offline
external usenet poster
 
Posts: 1,002
Default Insert Paragraph Mark in all Table Cells

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




  #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





  #4   Report Post  
Posted to microsoft.public.word.tables
challa prabhu challa prabhu is offline
external usenet poster
 
Posts: 77
Default Insert Paragraph Mark in all Table Cells

Do the following:
1. Open the word document
2. Create a table with three cloumns - Just for an example.
3. Type just one character in each cell - Alternatevely copy the single
character and paste in other cells.
4. Select the whole table - click the table sysmbol on the left top corner
of the table.
5. On the Edit menu, click Replace.
6. Click the More button.
7. Click the curson in the Find what box, and then click the Special button.
8. Click Any character - ^? characters are entered in the box.
9. Click the curson in the Replace With box, and then click the Special
button.
8. Click Paragraph character- ^v characters are entered in the box.
9. Click Replace button.
Important: Do not click Replace all. Because you are highlighing the table,
the command has to be executed within the table only. You click Replace ALL
then all contents in the document will be replaced by the paragaraph mark.

Challa Prabhu

"Al" wrote:

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



Reply
Thread Tools
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
want cells in a table to copy data from cells in another table Conrad D. Farner Tables 2 September 27th 06 04:21 PM
How can I Insert a column into a table that contains split cells Kate Vaughn Tables 1 August 9th 06 05:48 AM
If I insert an Excel table I get a graph, not the cells I specifie Germán Tables 1 July 3rd 06 11:35 AM
Mark at end of paragraph lobolady Microsoft Word Help 2 May 26th 06 05:14 PM
Insert text from one file into the cells of a table in another? Gillmore (ACME SW) Tables 2 November 18th 05 09:49 PM


All times are GMT +1. The time now is 05:41 PM.

Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 Microsoft Office Word Forum - WordBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Word"