Check whether paragraphs exist formatted with the normal style

Posted on 2012-03-23
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
Question by:AndreasHermle
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
LVL 76

Assisted Solution

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.
LVL 76

Accepted Solution

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


Author Closing Comment

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

Regards, Andreas

Featured Post

Free Tool: SSL Checker

Scans your site and returns information about your SSL implementation and certificate. Helpful for debugging and validating your SSL configuration.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

Do you ever need to create a 20 page Word document for some testing purpose? Are you tired of copying & pasting old boring "lorem ipsum" text over and over again, increasing font size and line space in order to make the document 20+ pages long? Look…
You need to know the location of the Office templates folder, so that when you create new templates, they are saved to that location, and thus are available for selection when creating new documents.  The steps to find the Templates folder path are …
This video shows where to find the word count, how to display it, and what it breaks down to in Microsoft Word.
Learn how to create and modify your own paragraph styles in Microsoft Word. This can be helpful when wanting to make consistently referenced styles throughout a document or template.
Suggested Courses

734 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