Shape.LineStyle Property

Visio Automation Reference

Specifies the line style for an object. Read/write.

Version Information
 Version Added:  Visio 2.0



expression   A variable that represents a Shape object.

Return Value


Setting the LineStyle property is equivalent to selecting a line style from the Line Style list on the Format Shape toolbar in Microsoft Office Visio.

Setting a style to a nonexistent style generates an error. Setting one kind of style to an existing style of another kind (for example, setting the LineStyle property to a fill style) does nothing. Setting one kind of style to an existing style that has more than one set of attributes changes only the attributes for that component. For example, setting the LineStyle property to a style that has line, text, and fill attributes changes only the line attributes.

To preserve a shape's local formatting, use the LineStyleKeepFmt property.

Beginning with Microsoft Visio 2002, setting LineStyle to a zero-length string ("") will cause the master's style to be reapplied to the selection or shape. (Earlier versions generate a "no such style" exception.) If the selection or shape has no master, its style remains unchanged. Setting LineStyle to a zero-length string is the equivalent of selecting Use master's format in the Text style, Line style, or Fill style list in the Style dialog box (on the Format menu, click Style).


This Microsoft Visual Basic for Applications (VBA) macro shows how to use the LineStyle property to set the line style for a particular shape.

Visual Basic for Applications
Public Sub LineStyle_Example() 
Dim vsoShape As Visio.Shape 

Set vsoShape = ActivePage.DrawLine(5, 4, 7.5, 1) 
vsoShape.LineStyle = "Guide"

End Sub

See Also