logo
search
Office Settings & Configuration

How to Select a Heading and Body Text Until the Next Heading in Word

Maira MehtabMaira Mehtab Sep 20, 2026 869 views

Question details

The user wants to select a specific heading where the cursor is currently placed, along with all the subsequent body text, stopping exactly before the next heading begins.

Product
Word
Device & OS
not provided
Scenario
Editing a document and needing to quickly highlight or extract a section of content nested under a specific heading.
Observed behavior
Looking for an automated or built-in way to achieve this using a VBA macro or Word Outline View.
Before you start

Ensure your document is formatted with built-in heading styles (e.g., Heading 1, Heading 2), as both VBA macros and Outline View rely on these styles to properly identify document sections.

Solution 1Recommended

Use a VBA Macro to Select the Current Heading Section

Use a simple VBA macro to automatically select the heading where your cursor is located and all its subordinate content.

By utilizing Word's built-in bookmark system for heading levels, a short VBA script can instantly highlight the current section.

This method is highly efficient for repetitive tasks or when processing large documents.

1
Open the VBA Editor

Press Alt + F11 on your keyboard to open the Visual Basic for Applications (VBA) editor.

2
Insert a New Module

In the top menu, click 'Insert' and then select 'Module' to create a blank workspace.

3
Paste the Macro Code

Copy and paste the following code into the module window: Sub Demo() Selection.GoTo What:=wdGoToBookmark, Name:="\HeadingLevel" Selection.Select End Sub

4
Run the Macro

Place your cursor inside the target heading or its body text in your document, then return to the VBA editor and press F5 to run the macro.

Shortcut Tip: You can assign this macro to a custom keyboard shortcut or a Quick Access Toolbar button for even faster execution in the future.
Efficient Document Editing

Easily Manage Headings and Content in WPS Writer

WPS Writer offers full compatibility with Microsoft Word documents, including heading styles, Outline View, and advanced formatting tools. It allows you to organize and select document sections effortlessly.

  1. 1. Open the Document: Launch WPS Writer and open your document containing the headings.
  2. 2. Access Outline View: Go to the 'View' tab and click on the 'Outline' button.
  3. 3. Select the Content: Click the structural icon next to any heading to highlight the entire section at once.
  4. 4. Use the Navigation Pane: Alternatively, open the Navigation Pane from the View tab to quickly jump between headings or select sections.
Fully compatible with Microsoft Word document formats (.docx, .doc).Built-in Outline View for quick heading and paragraph selection.Intuitive Navigation Pane to easily view and manage document structure.Lightweight, fast-loading, and completely free to use.
microsoft office alternative - wps office

Frequently Asked Questions

Why does the VBA macro select more text than expected?

If the macro selects text past what you expect, check your document's formatting styles. The macro selects content until it encounters the next heading of the same or higher level. Ensure the subsequent section is properly formatted with a heading style.

Can I select a heading and its content without Outline View or VBA?

Yes, you can use the Navigation Pane. Go to View > Navigation Pane, locate the desired heading in the list, right-click it, and choose 'Select Heading and Content'.

Does this VBA macro work in WPS Office?

Yes, WPS Office supports VBA macros in its professional editions. You can run the exact same `wdGoToBookmark` code in the WPS VBA editor to achieve the same result.

What happens if my cursor is in the middle of a paragraph?

If your cursor is anywhere within the body text under a heading, running the macro will automatically identify the parent heading above it and select that heading along with all associated body text up to the next equivalent heading.