Prevent Row Breaking in all Tables with a Single Click Using VBA
Preventing row breaking of a single or small number of tables (such one, two or three) is not a big deal, you can do it manually through table properties. However, when dealing with large documents containing many tables, then manually managing and preventing row breaking or splitting across pages can become time-consuming, challenging and boring task. Using VBA Code we can Prevent row breaking in all tables with single click in a Word document quickly and easily.
The following step by step process illustrate how to stop row breaking across pages in a word using macros and VBA code.
- Open VBA Editor (by Pressing ALT+F11), from the Menu Click on Insert Menu , then click on Module and Past the Following Code inside the module.
Sub preventAllTablesRowBreaking()
If ActiveDocument.Tables.Count > 0 Then
Dim wtbl As Table
For Each wtbl In ActiveDocument.Tables
wtbl.Rows.AllowBreakAcrossPages = False
Next
End If
End Sub
- After Pasting the aforementioned code, Press CTRL+S to Save your VBA Coded Macros and then Close the VBA Editor.
- To Test your VBA Coded Macro Press ALT+F8 , Marcos Dialog Box will Appear containing a list of VBA Coded Macros select your created one from the list and then press RUN Button.
If you’re unsure how to use and RUN VBA Code Properly, Click Here to learn in detail how to use and RUN VBA Code.
I hope this tutorial will help you to stop or prevent row breaking in all tables in a word document with a single click using VBA Code. If you have any queries please feel free to contact us using the detail given on our contact us page.
Thank you.