Assigning styles to all text in a Word document

Posted on 2012-08-14
Last Modified: 2012-08-14
Hi, Here's what I'm trying to do to a long Word document:

There are currently no styles assigned anywhere in the document.  I'd like to select all text of a certain font, and assign a style to that text.  Then select all text of a different font, and assign a different style to that text, and continue for about six or seven fonts.  Then I can easily change those fonts for the entire document if I wish.

Can't quite figure out a rapid way to do this, though.
Question by:StevenMiles
    LVL 23

    Expert Comment

    As far as I know there is NO option to select text of a certain font.  You will have to manually select each text section.
    LVL 76

    Accepted Solution

    You can use a macro like this:

    Sub SetStyle()
        With ActiveDocument.Range.Find
            .Font.Name = "Times New Roman"
            .Replacement.Style = "Emphasis"
            .Execute Replace:=wdReplaceAll
        End With
    End Sub

    Author Comment

    GrahamSkan, you definitely have me very close.  I've been experimenting, and I'd like to be able to take instances of bold text and assign that text to its own style.  I replaced
    .Font.Name = "Times New Roman"
    .Font.Bold = True

    but when I run the macro, it takes the entire paragraph that contains the bold text and converts the entire paragraph to the new style.  Is there a way to do this one word at a time?
    LVL 76

    Expert Comment

    What sort of style are you trying to apply? If it is a paragraph style, then that will happen. You need to use a character style.

    Author Comment

    Wow, okay.  Now I think I can do what I need to do. Thanks for the help

    Write Comment

    Please enter a first name

    Please enter a last name

    We will never share this with anyone.

    Featured Post

    Why You Should Analyze Threat Actor TTPs

    After years of analyzing threat actor behavior, it’s become clear that at any given time there are specific tactics, techniques, and procedures (TTPs) that are particularly prevalent. By analyzing and understanding these TTPs, you can dramatically enhance your security program.

    Shortcuts in Word Just the other day I had a training for Microsoft and they wanted me to show how well the new Windows and Office behaved on a touch device, which by the way is great, but it was only then that I realized that using keyboard shortc…
    This is written from a 'VBA for MS Word' perspective, but I am sure it applies to most other MS Office components where VBA is used.  One thing that really bugs me is slow code, ESPECIALLY when it's mine!  In programming there are so many ways to…
    This video walks the viewer through the process of creating envelopes and labels, with multiple names and addresses. Navigate to the “Start Mail Merge” button in the Mailings tab: Follow the step-by-step process until asked to find the address doc…
    This video shows where to find templates, what they are used for, and how to create and save a custom template using Microsoft Word.

    760 members asked questions and received personalized solutions in the past 7 days.

    Join the community of 500,000 technology professionals and ask your questions.

    Join & Ask a Question

    Need Help in Real-Time?

    Connect with top rated Experts

    8 Experts available now in Live!

    Get 1:1 Help Now