View Single Post
 
Old 10-16-2020, 04:50 PM
John 4 John 4 is offline Windows 10 Office 2013
Advanced Beginner
 
Join Date: Oct 2019
Posts: 69
John 4 is on a distinguished road
Default Insert a Paragraph mark before and after a table

Word often (always?) leaves no space above and below tables. I'd like to add a paragraph before and after the table. I could have simply selected the table, then collapsed the selection to before or after the table and added paras that way, but if there's no text between the tables Word butts them tight against each other so that that method doesn't work in those cases.

I thought I had it figured out by cutting the table, inserting the paras, and then pasting the table back in again. However Word appears to treat the pasted table as a new table and performs the operation on that table again (to infinity probably).

Is there a way to get the loop to move on to the next table? Perhaps assigning a value to each table (which will be recognised after pasting it back in again). I've tried this but it takes me an age (and countless error messages) to get anything done.

Thanks for your help.

Code:
Sub AddParaB4andAfterTables()
Dim oTable As Table
For Each oTable In ActiveDocument.Tables
  oTable.Select
  Selection.Cut
  Selection.InsertParagraphBefore
  Selection.InsertParagraphBefore
  Selection.Collapse Direction:=wdCollapseStart
  Selection.Move Unit:=wdCharacter, Count:=1
  Selection.Paste
Next
End Sub
Reply With Quote