Nota:
El acceso a esta página requiere autorización. Puede intentar iniciar sesión o cambiar directorios.
El acceso a esta página requiere autorización. Puede intentar cambiar los directorios.
Una colección de TextStyle objetos que representan los estilos integrados y definidos por el usuario en un documento.
Comentarios
Utilice la propiedad Document.TextStyles para devolver la colección TextStyles .
Utilice la ventana Agregar método para crear un nuevo estilo definido por el usuario y agregarlo a la colección TextStyles.
Ejemplo:
En el ejemplo siguiente se crea una tabla y enumera todos los estilos de la publicación activa.
Sub ListTextStyles()
Dim sty As TextStyle
Dim tbl As Table
Dim intRow As Integer
With ActiveDocument
Set tbl = .Pages(1).Shapes.AddTable(NumRows:=.TextStyles.Count, _
NumColumns:=2, Left:=72, Top:=72, Width:=488, Height:=12).Table
For Each sty In .TextStyles
intRow = intRow + 1
With tbl.Rows(intRow)
.Cells(1).text = sty.Name
.Cells(2).text = sty.BaseStyle
End With
Next sty
End With
End Sub
En el ejemplo siguiente se crea un nuevo estilo y se aplica al párrafo en la posición del cursor.
Sub ApplyTextStyle()
Dim styNew As TextStyle
Dim fntStyle As Font
'Create a new style
Set styNew = ActiveDocument.TextStyles.Add(StyleName:="NewStyle")
Set fntStyle = styNew.Font
'Format the Font object
With fntStyle
.Name = "Tahoma"
.Size = 20
.Bold = msoTrue
End With
'Apply the Font object formatting to the new style
styNew.Font = fntStyle
'Apply the new style to the selected paragraph
Selection.TextRange.ParagraphFormat.TextStyle = "NewStyle"
End Sub
Métodos
Propiedades
Vea también
Soporte técnico y comentarios
¿Tiene preguntas o comentarios sobre VBA para Office o esta documentación? Vea Soporte técnico y comentarios sobre VBA para Office para obtener ayuda sobre las formas en las que puede recibir soporte técnico y enviar comentarios.