How to Change the Border Width of All Tables in Word Using VBA
Question details
The user needs to automatically update the border width of all tables in a Word document from 0.5 points to 1.5 points.

- Product
- Word
- Device & OS
- not provided
- Scenario
- Applying consistent table formatting across a long Word document containing multiple tables.
- Observed behavior
- Manually changing table borders is too time-consuming, requiring an automated VBA macro solution to efficiently update the entire document.
Before running any VBA macro, ensure you save a backup copy of your Word document, as macro actions cannot typically be undone using the standard Undo button.
Use a VBA Macro to Update All Table Borders
Applying a VBA macro is the most efficient way to loop through all tables and adjust the border width to 1.5 points simultaneously.
This method utilizes a VBA macro to automatically adjust the line width for all table sides and inner borders.
To significantly improve performance on long documents with hundreds of pages, the macro should disable screen updating while processing the tables.
Open your document in Word and press Alt + F11 to launch the Visual Basic for Applications (VBA) Editor.
In the VBA Editor, click 'Insert' from the top menu and select 'Module' to create a blank workspace for your code.
Copy and paste your macro code into the module window. Ensure the code loops through ActiveDocument.Tables and sets the respective border widths to the wdLineWidth150pt constant.
Press F5 or click the 'Run' button in the toolbar to execute the script. Once finished, close the VBA Editor to view your updated tables.

Modify Code for Tables Without Existing Borders
If your document contains tables without any existing borders, a standard macro might fail. You must ensure a border format is applied first.
Manage Word Tables Easily with WPS Office
WPS Writer offers advanced table formatting tools and high compatibility with Microsoft Word documents. You can easily adjust table properties, apply uniform styles, and handle complex formatting tasks efficiently without writing code.
- 1. Download and Install: Download and install WPS Office Free from the official website.
- 2. Open Your Document: Launch WPS Writer and open your .docx document containing the tables.
- 3. Format Tables Easily: Select the tables you wish to format, navigate to the 'Table Tools' tab, and use the built-in properties to adjust border widths consistently.

Frequently Asked Questions
Why does my table formatting macro run so slowly on a long document?
Macros can run slowly if Word tries to redraw the document on the screen after every single change. Adding the command 'Application.ScreenUpdating = False' at the beginning of your script prevents this continuous refreshing and dramatically speeds up the process.
What VBA constant do I use for a 1.5-point border width?
In Word VBA, you should use the exact constant 'wdLineWidth150pt' to set a table border width to 1.5 points.
Will a width macro work if some tables don't have borders at all?
If your macro only changes the width of existing borders, it may fail or skip tables that have no borders applied. To fix this, ensure your VBA code first applies a border line style (like 'wdLineStyleSingle') before attempting to modify the width.




