VBA & Macro Problems

How to Change the Border Width of All Tables in Word Using VBA

John WilsonJohn Wilson Oct 26, 2026 870 views

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.

How to Change the Border Width of All Tables in Word
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 you start

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.

Solution 1Recommended

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.

1
Open the VBA Editor

Open your document in Word and press Alt + F11 to launch the Visual Basic for Applications (VBA) Editor.

2
Insert a New Module

In the VBA Editor, click 'Insert' from the top menu and select 'Module' to create a blank workspace for your code.

3
Enter the Macro 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.

4
Run the Macro

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.

Use a VBA Macro to Update All Table Borders
Performance Tip: Include 'Application.ScreenUpdating = False' at the start of your macro and set it to 'True' at the end to drastically speed up execution on large documents.
Efficient Document Formatting

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. 1. Download and Install: Download and install WPS Office Free from the official website.
  2. 2. Open Your Document: Launch WPS Writer and open your .docx document containing the tables.
  3. 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.
Fully compatible with Microsoft Word (.docx) formatsIntuitive table design and bulk formatting optionsLightweight application with fast performance on long documentsFree and easy-to-use Office suite
microsoft office alternative - wps office

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.