VBA & Macro Problems

Extract Formatted Text Blocks into a Word Summary with VBA

John WilsonJohn Wilson Nov 2, 2026 869 views

Question details

The user needs a method to collect multiple selected text areas from a document and compile them into a summary section using VBA.

How to Extract Formatted Text Blocks into a Word Summary with VBA
Product
Word
Device & OS
not provided
Scenario
Compiling specific, widely separated portions of text into an executive summary or overview section without losing their complex formatting.
Observed behavior
The word processor lacks a built-in direct command to automatically collect marked text blocks into a summary while preserving critical formatting like paragraphs and multilevel lists.
Before you start

Before writing your scripts, ensure the Developer tab is enabled in your ribbon settings. Verify that your document contains the specific multilevel lists and formatted text you intend to summarize so you can test the macro's output accurately.

Solution 1Recommended

Create VBA Macros Using Bookmarks and FormattedText

This method uses a set of small VBA macros to mark selections with unique bookmarks, compile their formatted text into a summary, and clean up the bookmarks afterward.

Using the FormattedText property in VBA is highly recommended because it preserves complex formatting, such as multilevel lists and paragraph styles, much better than standard string copying.

1
Open the VBA Editor

Press Alt + F11 to launch the Visual Basic for Applications (VBA) editor. Go to Insert > Module to create a new workspace for your code.

2
Write the Bookmark Macro

Create a macro that assigns a uniquely named bookmark (e.g., sequentially numbered like 'Summary_1', 'Summary_2') to the currently selected text.

3
Write the Compilation Macro

Draft a second macro that loops through all bookmarks matching your unique naming pattern. Use the code 'DestinationRange.FormattedText = SourceBookmark.Range.FormattedText' to insert each bookmark's exact formatting into the designated summary area.

4
Write a Cleanup Macro

Add a final script to delete the temporary bookmarks once the summary generation is complete. This keeps your document clean and prevents errors if you need to run the compilation again.

Create VBA Macros Using Bookmarks and FormattedText
Preserve Complex Formatting: By relying on the FormattedText property rather than standard copy-paste VBA commands, you ensure all lists, bolding, colors, and paragraph styles remain completely intact.
WPS Writer VBA Automation

Automate Document Summaries with WPS Writer

WPS Writer offers an intuitive Developer environment and robust macro support, allowing you to easily build VBA scripts to extract formatted text blocks and compile them into comprehensive summaries with exact layout preservation.

  1. 1. Enable Developer Tools: Open WPS Writer, go to 'Menu' > 'Options' > 'Customize Ribbon', and check the box for the 'Developer' tab to reveal macro settings.
  2. 2. Open the Macro Editor: Click 'Developer' on the main ribbon, then click 'Macro' or press Alt + F11 to launch the built-in WPS VBA editor.
  3. 3. Insert Your VBA Script: Create a new Module and paste your bookmarking and FormattedText compilation macros directly into the editor.
  4. 4. Run the Summary Macro: Select your text blocks, assign the bookmarks via your macro, and run the compilation script to instantly generate your formatted summary.
Seamless compatibility with Microsoft Word VBA macro scriptsPreserves intricate text formatting, paragraph styles, and multilevel lists perfectlyLightweight application with a familiar, user-friendly interfacePowerful document automation features available without heavy resource usage
microsoft office alternative - wps office

Frequently Asked Questions

Why does regular VBA text extraction lose my multilevel list formatting?

Standard VBA string extraction (like Range.Text) only copies the plain text values. To retain complex formatting like multilevel lists, indentations, or bolding, you must explicitly use the Range.FormattedText property in your macro script.

Can I use third-party add-ins to extract text instead of writing VBA code?

Yes, there are several free tools and templates created by Word MVPs that automate text extraction. However, these require downloading third-party software, which may require security review and additional setup before they can be safely used in a corporate environment.

Are VBA bookmarks visible in the final printed document?

No, bookmarks do not print. By default, they are hidden on the screen as well. You can make them visible for editing purposes in the document settings by checking 'Show bookmarks', which displays them as gray brackets. Running a cleanup macro ensures they are permanently removed.

Will VBA macros written for Word work in WPS Writer?

WPS Writer features high compatibility with standard Microsoft Word VBA scripts. Most macros utilizing standard objects like Bookmarks, Ranges, and FormattedText will run seamlessly in WPS Office, allowing for straightforward migration of your automated workflows.