Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 584653
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 13, 20262026-05-13T14:55:15+00:00 2026-05-13T14:55:15+00:00

Suppose I have a Range reference in Word VBA, and I want to break

  • 0

Suppose I have a Range reference in Word VBA, and I want to break that down into smaller ranges where the formatting (font, colour, etc.) is identical. For example, if I start with:

The quick brown fox jumped over the lazy dog.

…then I would want to get back 5 ranges, as follows:

The

quick

brown fox jumped over the

lazy

dog.

I had hoped that there was a built-in way to do this in VBA (and even have a phantom memory of using such a facility), but I can’t find anything.

I could do what I need to do in code, but something that works natively would be much (much) quicker.

[In code, I would use the fact that – for example – oRange.Font.Bold will return "undefined" if the range contains a mix of bold and not bold, and so I could use this repeatedly to discover the extent of the uniform ranges. But I’m pretty sure that Word will be doing this under the hood, so if someone can pop that hood for me, I’d be grateful.]

EDIT: removed more complex example that the StackOverflow HTML renderer did not like.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-13T14:55:15+00:00Added an answer on May 13, 2026 at 2:55 pm

    Can’t really do this in VBA as the OM doesn’t support runs (OOXML does however). The best you could probably do is get the wdUnits of wdCharacterFormatting and create a loop to create ranges, extract their properties and then destroy them until the loop is finished. You’d probaby start with something like:

    Dim sel As Selection
    Set sel = ActiveWindow.Selection
    Dim selRange As Range
    Set selRange = selRange.Next(wdCharacterFormatting)
    

    to get the start and end of the next set of formatting, like selRange.Start/selRange.End, as well as any properties like selRange.Font.Name/selRange.Bold.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Suppose I have some module in vba with some variable r of type Range
Suppose I have 65 people that register on January 1, 2012. I want to
Suppose I have range from E2 to E16. How do I read values from
Suppose I have a pure virtual method in the base interface that returns to
Suppose I have a static method of my class that returns an object of
Suppose I have a class Baz that inherits from classes Foo and Bar ,
Suppose I have a process that is updating a record and encounters a record
Suppose I have this range: (aaaaa..zzzzz) How would I get the Nth item from
Suppose that you have a directed graph with nonnegative, integer edge lengths that are
Suppose I have a range of keys, say 0 -> 1000 Say 0 -

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.