Home
Search
 
What's New
Index
Books
Links
Q & A
Newsletter
Banners
 
Feedback
Tip Jar
 
C# Helper...
 
XML RSS Feed
Follow VBHelper on Twitter
 
 
 
MSDN Visual Basic Community
 
 
 
 
 
TitleUse a VBA macro to number non-blank paragraphs in Word
DescriptionThis example shows how to let the user press Ctrl-A to select all of the text in a TextBox in Visual Basic 6.
Keywordsctrl-A, control-A, select text
CategoriesOffice
 
The NumberNonBlankParagraphs macro loops through the selected paragraphs and applies a number style to each that is non-blank.
 
' Number non-blank paragraphs.
Public Sub NumberNonBlankParagraphs()
Dim para As Paragraph

    For Each para In Selection.Paragraphs
        ' See if the paragraph is empty.
        If para.Range.Characters.Count > 1 Then
            ' It's not empty. Number it.
            para.Range.ListFormat.ApplyListTemplate _
                ListTemplate:=ListGalleries(wdNumberGallery).ListTemplates(5), _
                    _
                ContinuePreviousList:=True
        End If
    Next para
End Sub
 
 
Copyright © 1997-2010 Rocky Mountain Computer Consulting, Inc.   All rights reserved.
  Updated