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
  • 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: ZipGrep

ZipGrep is a utility that can list and search zip (.war, .ear, .jar, etc) archives for text patterns, without the need to extract the archive's contents.

One of a set of tools we're offering as a way to say 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

Suggested Solutions

Title # Comments Views Activity
stop word moving down 2 67
The blinking Office button 4 45
ms office troubleshooting for users 8 47
Word 2016 Installation Problem on Terminal Server 9 40
Introduction This tutorial provides instructions on how to properly format your Word document using the inbuilt tools provided. The benefits of using these tools means your documents are more accessible and easily portable to other applications an…
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 teaches the viewer how to align pictures around text while keeping the text properly aligned in the document.
This video walks the viewer through the process of creating Hyperlinks for the web and other documents. Select the "Insert" tab: Click "Hyperlink":  Type "http://" followed by a web address to reference a website or navigate to a document to ref…

830 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