How to move table captions from above to below or vice versa in Word document?
In a Word document, if there are multiple tables that have inserted captions below each table. But, sometimes, you may want to move these captions from below to above of the tables. How could you batch deal with this job as quickly as you can?
Move table captions from below to above or vice versa in Word with VBA code
Move table captions from below to above or vice versa in Word with VBA code
To move all table captions from below to above of the tables, the following VBA code do you a favor, please do as this:
1. Hold down the ALT + F11 keys to open the Microsoft Visual Basic for Applications window.
2. Click Insert > Module, and paste the following macro in the Module Window.
Move table captions from below to above in a Word document
Sub ReLabelDownToUpTables()
Dim I As Long
Dim xRngPre As Range
Dim xRngNext As Range
Application.ScreenUpdating = False
With ActiveDocument
For I = .Tables.Count To 1 Step -1
With .Tables(I).Range
Set xRngPre = .Characters.First.Previous.Characters.Last
xRngPre.Select
Set xRngNext = .Characters.Last.Next.Paragraphs.First.Range
xRngNext.Select
With xRngPre
.InsertBefore vbCr
.Style = xRngNext.Style
.Start = .End - 1
.End = .Start
End With
If Len(xRngNext.Text) > 1 Then
xRngNext.End = xRngNext.End - 1
xRngNext.Cut
xRngNext.Delete
xRngPre.Paste
Else
xRngNext.Delete
End If
End With
Next
End With
Application.ScreenUpdating = True
End Sub
3. Then, press F5 key to run this code, and all table captions have been moved from below to above of the tables, see screenshot:
Note: To move the table captions from above to below of each table, please apply the following VBA code:
Move table captions from above to below in a Word document
Sub ReLabelUpToDownTables()
Dim I As Long
Dim xRngPre As Range
Dim xRngNext As Range
Application.ScreenUpdating = False
With ActiveDocument
For I = .Tables.Count To 1 Step -1
With .Tables(I).Range
Set xRngNext = .Characters.First.Previous.Paragraphs.First.Range
xRngNext.Select
Set xRngPre = .Characters.Last.Next
xRngPre.End = xRngPre.End - 1
xRngPre.Select
With xRngPre
.InsertBefore vbCr
.Style = xRngNext.Style
.Start = .End - 1
.End = .Start
End With
If Len(xRngNext.Text) > 1 Then
xRngNext.End = xRngNext.End - 1
xRngNext.Cut
xRngNext.Delete
xRngPre.Paste
Else
xRngNext.Delete
End If
End With
Next
End With
Application.ScreenUpdating = True
End Sub
Insert multiple table, picture or equation captions into Word document at once :
Normally, you should inser the table, picture or equation caption for the table, image or equation one by one in Word file. But, if you have Kutols for Word's Multiple Captions feature, you can insert the table, image or equation captions for all tables, images or equations as quickly as possible. Kutools for Word: with more than 100 handy Word add-ins, free to try with no limitation in 60 days. Click to Download and free trial Now! |
Best Office Productivity Tools
Kutools for Word - Elevate Your Word Experience with Over 100 Remarkable Features!
Dive into the highlighted features below or click here to explore the full power of Kutools for Word.
๐ Document Mastery: Split Pages / Merge Documents / Export Selection in Various Formats (PDF/TXT/DOC/XLSX) / Batch Convert to PDF / Export Pages as Images / Print Multiple Files at once ...
โ Contents Editing: Batch Find and Replace across Multiple Files / Resize All Pictures / Transpose Table Rows and Columns / Convert Table to Text ...
๐งน Effortless Clean: Sweap away Extra Spaces / Section Breaks / All Headers / Text Boxes / Hyperlinks / For more removing tools, head to our Remove Group
โ Creative Inserts: Insert Thousand Separators / Check Boxes / Radio Buttons / QR Code / Barcode / Diagonal Line Table / Equation Caption / Image Caption / Table Caption / Multiple Pictures / Discover more in our Insert Group
๐ Precision Selections: Pinpoint specific pages / tables / shapes / heading paragraphs / Navigate with ease using our Select Group
โญ Star Enhancements: Navigate swiftly to any location / auto-insert repetitive text / seamlessly toggle between document windows / 11 Conversion Tools ...
Transform your Word tasks with Kutools. ๐ Download with 30-day trial Now ๐.
