Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

Check whether paragraphs exist formatted with the normal style

Posted on 2012-03-23
3
Medium Priority
?
637 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 2000 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 2000 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

New feature and membership benefit!

New feature! Upgrade and increase expert visibility of your issues with Priority Questions.

Question has a verified solution.

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

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 article shows how to get a list of available printers for display in a drop-down list, and then to use the selected printer to print an Access report or a Word document filled with Access data, using different syntax as needed for working with …
In this video, we show how to convert an image-only PDF file into a PDF Searchable Image file, that is, a file with both the image (typically from scanning) and text, which is created in an automated fashion with Optical Character Recognition (OCR) …
The viewer will learn how to make their project stand out over others by learning how to change colors and shapes, add spaces, change directions, and add bullets to their charts.

972 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