Style Property

Microsoft Word Visual Basic

Returns or sets the line format style. Read/write MsoLineStyle.

MsoLineStyle can be one of these MsoLineStyle constants.
msoLineSingle
msoLineThickBetweenThin
msoLineThinThick
msoLineStyleMixed
msoLineThickThin
msoLineThinThin

expression.Style

expression    Required. An expression that returns a LineFormat object.

ShowStyle property as it applies to the EmailAuthor and Revision objects.

Returns a Style object that represents the style associated with the current e-mail author for unsent replies, forwards, or new e-mail messages.

expression.Style

expression    Required. An expression that returns one of the above objects.

ShowStyle property as it applies to the Find, HeadingStyle, Paragraph, ParagraphFormat, Paragraphs, Range, Replacement, Selection, and Table objects.

Returns or sets the style for the specified object. To set this property, specify the local name of the style, an integer, a WdBuiltinStyle constant, or an object that represents the style. For a list of valid constants, consult the Microsoft Visual Basic Object Browser. Read/write Variant.

expression.Style

expression    Required. An expression that returns one of the above objects.

Remarks

When you return the style for a range that includes more than one style, only the first character or paragraph style is returned.

Example

ShowAs it applies to the EmailAuthor object.

This example returns the style associated with the current author for unsent replies, forwards, or new e-mail messages and displays the name of the font associated with this style.

Set MyEmailStyle = _
    ActiveDocument.Email.CurrentEmailAuthor.Style
Msgbox MyEmailStyle.Font.Name
				

ShowAs it applies to the Paragraph object.

This example displays the style for each paragraph in the active document.

For Each para in ActiveDocument.Paragraphs
    MsgBox para.Style
Next para
				

This example sets alternating styles of Heading 3 and Normal for all the paragraphs in the active document.

For i = 1 To ActiveDocument.Paragraphs.Count
    If i Mod 2 = 0 Then
        ActiveDocument.Paragraphs(i).Style = wdStyleNormal
    Else: ActiveDocument.Paragraphs(i).Style = wdStyleHeading3
    End If
Next i
				

ShowAs it applies to the Range object.

This example displays the style for each character in the selection. Each element of the Characters collection is a Range object.

For each c in Selection.Characters
    MsgBox c.Style
Next c