Ver Mensaje Individual
  #1 (permalink)  
Antiguo 13/06/2007, 14:57
santigh82
 
Fecha de Ingreso: junio-2007
Mensajes: 5
Antigüedad: 16 años, 11 meses
Puntos: 0
Alinear texto de word con codigo Visual Basic

Hola,tengo un formulario de inicio y pretendo q cambie el estilo del texto del documento word mediante dicho formulario pero no me sale lo de alinearlo a derechas izquierdas y centro,si lo de negrita y cursiva y eso.Podeis decirme como hacerlo?

Adjunto micodigo para el formulario (llamado inicio)

Código:
Dim neg, cur, subr As Boolean
Dim alineacion
Dim color
Dim tamaño
Private Sub cbxColor_Change()
Select Case cbxColor.ListIndex
Case 0
color = azul
lblTam.ForeColor = &HFF0000
Case 1
color = rojo
lblTam.ForeColor = &HFF&
Case 2
color = verde
lblTam.ForeColor = &H8080&
Case 3
color = blanco
lblTam.ForeColor = &HFFFFFF
End Select
End Sub
Private Sub cmbDocumento_Click()
For i = 1 To 8
ActiveDocument.Paragraphs(i).Range.Select
Select Case cbxColor.ListIndex
Case 0
Selection.Font.ColorIndex = wdBlue
Case 1
Selection.Font.ColorIndex = wdRed
Case 2
Selection.Font.ColorIndex = wdGreen
Case 3
Selection.Font.ColorIndex = wdWhite
End Select
Selection.Font.Size = tamaño

If neg = True Then Selection.Font.Bold = wdToggle
If cur = True Then Selection.Font.Italic = wdToggle
If subr = True Then Selection.Font.Underline = wdUnderlineSingle
Next i
Inicio.Hide
End Sub
Private Sub cvrCursiva_Click()
If cur = False Then
lblTam.Font.Italic = True
cur = True
Else
lblTam.Font.Italic = False
cur = False
End If
End Sub
Private Sub cvrNegrita_Click()
If neg = False Then
lblTam.Font.Bold = True
neg = True
Else
lblTam.Font.Bold = False
neg = False
End If
End Sub
Private Sub cvrSubrayado_Click()
If subr = False Then
lblTam.Font.Underline = True
subr = True
Else
lblTam.Font.Underline = False
subr = False
End If
End Sub
Private Sub centro_Click()
Selection.ParagraphFormat.Alignment = wdAlignParagraphCenter
alineacion = centro
End Sub
Private Sub derecha_Click()
Selection.ParagraphFormat.Alignment = wdAlignParagraphRight
alineacion = derecha
End Sub
Private Sub izquierda_Click()
Selection.ParagraphFormat.Alignment = wdAlignParagraphLeft
alineacion = izquierda
End Sub
Private Sub scbTam_Change()
Select Case scbTam.Value
Case Is < 10
lblTam.Font.Size = 8
lblt.Caption = "8"
tamaño = 8
Case Is < 20
lblTam.Font.Size = 10
lblt.Caption = "10"
tamaño = 10
Case Is < 30
lblTam.Font.Size = 12
tamaño = 12
lblt.Caption = "12"
Case Is < 40
lblTam.Font.Size = 14
tamaño = 14
lblt.Caption = "14"
Case Is < 50
lblTam.Font.Size = 16
tamaño = 16
lblt.Caption = "16"
Case Is < 60
lblTam.Font.Size = 18
tamaño = 18
lblt.Caption = "18"
Case Is < 70
lblTam.Font.Size = 20
tamaño = 20
lblt.Caption = "20"
End Select
End Sub
Private Sub UserForm_Activate()
neg = False
cur = False
subr = False
alineacion = izquierda
color = negro
tamaño = 8
With cbxColor
.AddItem "Azul"
.AddItem "Rojo"
.AddItem "Verde"
.AddItem "Blanco"
End With
End Sub