Solved

Check whether paragraphs exist formatted with the normal style

Posted on 2012-03-23
3
629 Views
Last Modified: 2012-03-23
Dear Experts:

I would like to run a macro that performs the following actions:

Check whether there are paragraphs formatted with the Normal style in the current document. If any are found the complete paragraph is to be highlighted yellow.

Help is much appreciated. Thank you very much in advance.

Regards, Andreas
0
Comment
Question by:AndreasHermle
  • 2
3 Comments
 
LVL 76

Assisted Solution

by:GrahamSkan
GrahamSkan earned 500 total points
ID: 37756423
Interesting, Andreas.

I tried coding the Find object, but couldn't get it to work. I even tried recording a Find. The Find worked, but the recording didn't. Perhaps that's why you posted the question.

This walk through the document's paragraphs does work
Function AnyNormalStyleInDoc() As Boolean
    Dim para As Paragraph
    
    For Each para In ActiveDocument.Paragraphs
        If para.Style = "Normal" Then
            AnyNormalStyleInDoc = True
            Exit For
        End If
    Next para
End Function

Open in new window


Just noticed that I haven't done the highlighting, so I'll do that bit now.
0
 
LVL 76

Accepted Solution

by:
GrahamSkan earned 500 total points
ID: 37756440
This will highlight the paragraphs
Sub HighlightNormalStyleParas()
    Dim para As Paragraph
    
    For Each para In ActiveDocument.Paragraphs
        If para.Style = "Normal" Then
            para.Range.HighlightColorIndex = wdYellow
        End If
    Next para
End Sub

Open in new window

0
 

Author Closing Comment

by:AndreasHermle
ID: 37756957
Great job, Graham, as always. Thank you very much.

Regards, Andreas
0

Featured Post

What Should I Do With This Threat Intelligence?

Are you wondering if you actually need threat intelligence? The answer is yes. We explain the basics for creating useful threat intelligence.

Join & Write a Comment

Introduction Authors who set out to write any sort of lengthy piece for online submission—be it a long question or comment on a technical form, an article, or a substantial blog entry—often find it useful to work up a draft in an editor other t…
If you work with Word a lot, you probably use styles. If you use styles a lot, you've probably balled your fist more often than not when working with the ribbon. In Word 2007/2010, one of the things that I find missing when using styles is a quic…
This video shows and describes the main difference between both orientations in Microsoft Word. Viewers will understand when to use each orientation and how to get the most out of them.
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…

744 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

11 Experts available now in Live!

Get 1:1 Help Now