Home |
Search |
Today's Posts |
#1
Posted to microsoft.public.word.tables
|
|||
|
|||
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
Posted to microsoft.public.word.tables
|
|||
|
|||
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
Posted to microsoft.public.word.tables
|
|||
|
|||
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
Posted to microsoft.public.word.tables
|
|||
|
|||
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 | |
|
|
Similar Threads | ||||
Thread | Forum | |||
want cells in a table to copy data from cells in another table | Tables | |||
How can I Insert a column into a table that contains split cells | Tables | |||
If I insert an Excel table I get a graph, not the cells I specifie | Tables | |||
Mark at end of paragraph | Microsoft Word Help | |||
Insert text from one file into the cells of a table in another? | Tables |