Style Property [Visio 2003 SDK Documentation]
As it applies to the Cell object.
Gets the style that contains a Cell object.
objRet = object**.Style**
objRet A Style object that represents the style containing the cell.
object Required. An expression that returns a Cell object.
Version added
2.0
Remarks
If a style consists of different text, line, and fill styles, the Style property returns the fill style.
If a Cell object is in a style, its Style property returns the style that contains the cell, and its Shape property returns Nothing.
If a Cell object is in a shape, its Shape property returns the shape that contains the cell, and its Style property returns Nothing.
As it applies to the Menu, MenuItem, and ToolbarItem objects.
Determines whether a menu item or toolbar button shows an icon, a caption, or some combination.
intRet = object**.Style**()
object**.Style** = intExpression
intRet Integer. The current style of a menu item or toolbar button.
object Required. An expression that returns a Menu , MenuItem, or ToolbarItem object.
intExpression Required Integer. The new style for a menu item or toolbar button.
Remarks
Possible values for intRet and intExpression are listed in the following table. These constants are declared by the Visio type library in VisUIButtonStyle.
Constant | Value |
---|---|
visButtonAutomatic |
0 |
visButtonCaption |
1 |
visButtonIcon |
2 |
visButtonIconandCaption |
3 |
As it applies to the Row object.
Gets the style that contains a Row object.
objRet = object**.Style**
objRet A Style object that represents the style containing the row.
object Required. An expression that returns a Row object.
Version added
2.0
Remarks
If a style consists of different text, line, and fill styles, the Style property returns the fill style.
If a Row object is in a style, its Style property returns the style that contains the cell, and its Shape property returns Nothing.
If a Row object is in a shape, its Shape property returns the shape that contains the cell, and its Style property returns Nothing.
As it applies to the Section object.
Gets the style that contains a Section object.
objRet = object**.Style**
objRet A Style object that represents the style containing the section.
object Required. An expression that returns a Section object.
Version added
2.0
Remarks
If a style consists of different text, line, and fill styles, the Style property returns the fill style.
If a Section object is in a style, its Style property returns the style that contains the cell, and its Shape property returns Nothing.
If a Section object is in a shape, its Shape property returns the shape that contains the cell, and its Style property returns Nothing.
As it applies to the Selection object.
Gets or sets the style for a Selection object.
strRet = object**.Style**
object**.Style** = stringExpression
strRet String. The fill style component of the style.
object Required. An expression that returns a Selection object that has or gets the style.
stringExpression Required String. The name of the style to apply.
Version added
2.0
Remarks
If a style consists of different text, line, and fill styles, the Style property returns the fill style. If you set the Style property to a nonexistent style, your program generates an error.
To preserve local formatting, use the StyleKeepFmt property.
Beginning with Visio 2002, setting stringExpression to an empty string ("") will cause the master's style to be reapplied to the shape. (Earlier versions generate a "no such style" exception.) If the shape has no master, its style remains unchanged. Setting stringExpression to an empty 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 (Format menu).
As it applies to the Shape object.
Gets or sets the style for a Shape object.
strRet = object**.Style**
object**.Style** = stringExpression
strRet String. The fill style component of the style.
object Required. An expression that returns a Shape object that has or gets the style.
stringExpression Required String. The name of the style to apply.
Version added
2.0
Remarks
If a style consists of different text, line, and fill styles, the Style property returns the fill style. If you set the Style property to a nonexistent style, your program generates an error.
To preserve local formatting, use the StyleKeepFmt property.
Beginning with Visio 2002, setting stringExpression to an empty string ("") will cause the master's style to be reapplied to the shape. (Earlier versions generate a "no such style" exception.) If the shape has no master, its style remains unchanged. Setting stringExpression to an empty 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 (Format menu).
Example
As it applies to the ToolbarItem object.
This example shows how to use the Style property to set the style of a toolbar button. The example adds a custom toolbar button and sets it to display both an icon and a caption. This button appears in the Visio user interface and is available while the document is active.
Before running this code, replace path\filename with the full path to and name of a valid icone (.ico) file on your computer.
To restore the built-in toolbars in Microsoft Office Visio after you run this macro, call the ThisDocument.ClearCustomToolbars method.
Sub Style_Example()
Dim vsoUIObject As Visio.UIObject
Dim vsoToolbarSet As Visio.ToolbarSet
Dim vsoToolbarItems As Visio.ToolbarItems
Dim vsoToolbarItem As Visio.ToolbarItem
'Check whether there are document custom toolbars.
If ThisDocument.CustomToolbars Is Nothing Then
'If not, check whether there are application custom toolbars.
If Visio.Application.CustomToolbars Is Nothing Then
'If not, use the built-in toolbars.
Set vsoUIObject = Visio.Application.BuiltInToolbars(0)
Else
'If there are application custom toolbars, copy them.
Set vsoUIObject = Visio.Application.CustomToolbars.Clone
End If
Else
'If there already are document custom toolbars, use them.
Set vsoUIObject = ThisDocument.CustomToolbars
End If
'Get the Toolbars collection for the drawing window context.
Set vsoToolbarSet = vsoUIObject.ToolbarSets.ItemAtID(visUIObjSetDrawing)
'Get the set of toolbar items for the Standard toolbar.
Set vsoToolbarItems = vsoToolbarSet.Toolbars(0).ToolbarItems
'Add a new button in the first position.
Set vsoToolbarItem = vsoToolbarItems.AddAt(0)
'Set properties for the new toolbar button.
vsoToolbarItem.CntrlType = visCtrlTypeBUTTON
vsoToolbarItem.CmdNum = visCmdFileSave
vsoToolbarItem.Style = visButtonIconandCaption
vsoToolbarItem.IconFileName "path\filename"
'Use the new UIObject object while this document is active.
ThisDocument.SetCustomToolbars vsoUIObject
End Sub
Applies to | Cell object | Menu object | MenuItem object | Row object | Section object | Selection object | Shape object | ToolbarItem object
See Also | FillStyle property | LineStyle property | Shape property | StyleKeepFmt property | TextStyle property