- Joined
- Jan 2, 2020
- Messages
- 16
- Reaction score
- 0
Hey folks,
My people like their table captions included in the first row of a table so the caption repeats on following pages. I've written a pretty basic macro to cut a table caption, go to the table and insert a row, merge the cells, and paste the caption into that row. It works great except for one thing: because the caption is usually immediately followed by a table, cutting the caption leaves the blank paragraph marker behind (I'm sure there's a good technical reason Word does this but it's annoying).
Here's my code:
Sub PutCaptionIntoTable()
'
'
Selection.Paragraphs(1).Range.Select
Selection.Cut
Selection.GoToNext wdGoToTable
Selection.InsertRowsAbove 1
Selection.Cells.Merge
Selection.Paste
With Selection.Cells
.Borders(wdBorderLeft).LineStyle = wdLineStyleNone
.Borders(wdBorderRight).LineStyle = wdLineStyleNone
.Borders(wdBorderTop).LineStyle = wdLineStyleNone
.Borders(wdBorderDiagonalDown).LineStyle = wdLineStyleNone
.Borders(wdBorderDiagonalUp).LineStyle = wdLineStyleNone
.Borders.Shadow = False
End With
Selection.Style = Word.WdBuiltinStyle.wdStyleCaption
End Sub
What's the most efficient way to delete that extra paragraph?
Thanks in advance,
Beej
My people like their table captions included in the first row of a table so the caption repeats on following pages. I've written a pretty basic macro to cut a table caption, go to the table and insert a row, merge the cells, and paste the caption into that row. It works great except for one thing: because the caption is usually immediately followed by a table, cutting the caption leaves the blank paragraph marker behind (I'm sure there's a good technical reason Word does this but it's annoying).
Here's my code:
Sub PutCaptionIntoTable()
'
'
Selection.Paragraphs(1).Range.Select
Selection.Cut
Selection.GoToNext wdGoToTable
Selection.InsertRowsAbove 1
Selection.Cells.Merge
Selection.Paste
With Selection.Cells
.Borders(wdBorderLeft).LineStyle = wdLineStyleNone
.Borders(wdBorderRight).LineStyle = wdLineStyleNone
.Borders(wdBorderTop).LineStyle = wdLineStyleNone
.Borders(wdBorderDiagonalDown).LineStyle = wdLineStyleNone
.Borders(wdBorderDiagonalUp).LineStyle = wdLineStyleNone
.Borders.Shadow = False
End With
Selection.Style = Word.WdBuiltinStyle.wdStyleCaption
End Sub
What's the most efficient way to delete that extra paragraph?
Thanks in advance,
Beej