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 3357004
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 18, 20262026-05-18T02:34:54+00:00 2026-05-18T02:34:54+00:00

So this is what I want to do, if it’s possible. I’ve got a

  • 0

So this is what I want to do, if it’s possible.
I’ve got a lot of rich textboxes in a Word template. And I want to create a macro that basically checks if any characters in the text entered into the placeholder is formatted with superscript, subscript, bold or underline etc.

So, What I’ve got so far is this

Dim i As Long
Dim txtboxString as String
For i = 1 To ActiveDocument.ContentControls.Count

    If ActiveDocument.ContentControls(i).Title = "Repporttitle" Or ActiveDocument.ContentControls(i).Title = "Subtitle" Then
        If ActiveDocument.ContentControls(i).LockContentControl = True Then
            ActiveDocument.ContentControls(i).LockContentControl = False
        End If
        txtboxString = ActiveDocument.ContentControls(i).Range.Text

    End If
Next i

So, now, txtboxString contains the text that was typed into the placeholder. But I want to check each letter for it’s formatting. The method above only gives me the text as a simple text string. I’ve seen that I can check each letter of the string this way:

Dim counter as integer
Dim contentText as string '(this is passed on via the above txtboxString)
Dim letter as string

For counter = 1 To Len(contentText)
    letter = Mid(contentText, counter, 1)
Next

But, this won’t give me the formatting of each letter. How can I do that?

  • 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-18T02:34:55+00:00Added an answer on May 18, 2026 at 2:34 am

    Use Characters and Font instead of Text. Like this:

    Sub GetCharacterFormatting()
    Dim i As Long
    Dim txtboxString As Characters ''# <- this was changed from "String" to "Characters"
    Dim Bold As String
    Dim Italic As String
    Dim Subscript As String
    Dim CharacterFont As Font
    Dim ap As Document: Set ap = ActiveDocument
    For i = 1 To ap.ContentControls.Count
        If ap.ContentControls(i).Title = "Repporttitle" Or ap.ContentControls(i).Title = "Subtitle" Then
            If ap.ContentControls(i).LockContentControl = True Then
                ap.ContentControls(i).LockContentControl = False
            End If
            txtboxString = ap.ContentControls(i).Range.Characters ''# <- this was changed from "Text" to "Characters"
            Dim counter As Integer
            For counter = 1 To txtboxString.Count
                Index = counter
                CharacterText = txtboxString(i).Text
                CharacterFont = txtboxString(i).Font
                ''# You can just grab all the formatting for the character or use If/Then statements
                Bold = "Bold: " & CharacterFont.Bold & ", "
                Italic = "Italic: " & CharacterFont.Italic & ", "
                Subscript = "Subscript: " & CharacterFont.Subscript & " "
                ''#
            Next
            Debug.Print Index & " (" & CharacterText & ") : " & Bold; Italic; Subscript
        End If
    Next i
    End Sub
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm not sure how to approach this: I want a TreeView that will display
I have a class that contains an array. I want this array to be
Here's a simple (hopefully) L10N question: Do all locales want this format: Sunday, Nov
I have this div: <div class=inauguration-image> I do not want this text to display,
My Invoice model has an address_id attribute, and I don't want this address_id to
This is similar to my previous posting. But this time I want to call
Perhaps I am not asking or searching for this correctly: I want to have
What logging library or approach would you recommend for this case: We want to
can ASP.NET controls be used with generics? Never seen this done and want a
I want to do this: //*fu which returns all nodes whose name ends in

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.