?
Solved

Assigning styles to all text in a Word document

Posted on 2012-08-14
5
Medium Priority
?
400 Views
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.
0
Comment
Question by:StevenMiles
  • 2
  • 2
5 Comments
 
LVL 23

Expert Comment

by:savone
ID: 38292182
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.
0
 
LVL 76

Accepted Solution

by:
GrahamSkan earned 1260 total points
ID: 38292564
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
0
 

Author Comment

by:StevenMiles
ID: 38292723
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"
with
.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?
0
 
LVL 76

Expert Comment

by:GrahamSkan
ID: 38292764
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.
0
 

Author Comment

by:StevenMiles
ID: 38292789
Wow, okay.  Now I think I can do what I need to do. Thanks for the help
0

Featured Post

[Webinar] Cloud and Mobile-First Strategy

Maybe you’ve fully adopted the cloud since the beginning. Or maybe you started with on-prem resources but are pursuing a “cloud and mobile first” strategy. Getting to that end state has its challenges. Discover how to build out a 100% cloud and mobile IT strategy in this webinar.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

It is often necessary in this forum and others to illustrate Word fields as text with the field delimiters replaced with the curly brackets that the delimiters resemble when field codes are being displayed on the document. This means that the text c…
I'm writing to share my clumsy experience in using this elegant tool so you can avoid every stupid mistake I made. (I leave it to the authorities to decide if this deserves a place in the Knowledge archives.)  Now that I am on the other side of my l…
This video teaches the viewer how to align pictures around text while keeping the text properly aligned in the document.
This video shows where to find templates, what they are used for, and how to create and save a custom template using Microsoft Word.
Suggested Courses

862 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