Foros del Web » Soporte técnico » Ofimática »

Alinear texto de word con codigo Visual Basic

Estas en el tema de Alinear texto de word con codigo Visual Basic en el foro de Ofimática en Foros del Web. 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 ...
  #1 (permalink)  
Antiguo 13/06/2007, 14:57
 
Fecha de Ingreso: junio-2007
Mensajes: 5
Antigüedad: 16 años, 10 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
  #2 (permalink)  
Antiguo 13/06/2007, 15:16
Avatar de abrahamvj  
Fecha de Ingreso: julio-2006
Ubicación: Lima, Peru
Mensajes: 708
Antigüedad: 17 años, 9 meses
Puntos: 18
Re: Alinear texto de word con codigo Visual Basic

Selection.ParagraphFormat.Alignment = wdAlignParagraphCenter
Selection.ParagraphFormat.Alignment = wdAlignParagraphRight
Selection.ParagraphFormat.Alignment = wdAlignParagraphLeft

Abraham
  #3 (permalink)  
Antiguo 13/06/2007, 15:21
 
Fecha de Ingreso: junio-2007
Mensajes: 5
Antigüedad: 16 años, 10 meses
Puntos: 0
Re: Alinear texto de word con codigo Visual Basic

Eso tengo puesto en los metodos pero no va!
  #4 (permalink)  
Antiguo 13/06/2007, 16:24
Avatar de abrahamvj  
Fecha de Ingreso: julio-2006
Ubicación: Lima, Peru
Mensajes: 708
Antigüedad: 17 años, 9 meses
Puntos: 18
Re: Alinear texto de word con codigo Visual Basic

si, acabo de volver todo tu codigo y ahi esta... pero: Cual es tu seleccion (Selection)?¿?¿¿ no tienes nada seleccionado, por lo tanto, nada se alinea!!!

Abraham
  #5 (permalink)  
Antiguo 14/06/2007, 03:24
 
Fecha de Ingreso: junio-2007
Mensajes: 5
Antigüedad: 16 años, 10 meses
Puntos: 0
Re: Alinear texto de word con codigo Visual Basic

Claro,selecciono de linea 3 a linea 9 en el for de arriba pero estos metodos son aparte entonces deberia meter el for dentro del metodo? El problema seria q al hacer mas grande el tamañao de la letra no seria la seleccion anterior pq habria cambiado
  #6 (permalink)  
Antiguo 14/06/2007, 10:29
Avatar de abrahamvj  
Fecha de Ingreso: julio-2006
Ubicación: Lima, Peru
Mensajes: 708
Antigüedad: 17 años, 9 meses
Puntos: 18
Re: Alinear texto de word con codigo Visual Basic

Porque no "culegas" el archivo para poder verlo y ayudarte mejor.

Abraham
  #7 (permalink)  
Antiguo 14/06/2007, 13:52
 
Fecha de Ingreso: junio-2007
Mensajes: 5
Antigüedad: 16 años, 10 meses
Puntos: 0
Re: Alinear texto de word con codigo Visual Basic

Te lo he mandado por mensaje privado.Ahora me da un fallo y me estoy volviendo loco....
  #8 (permalink)  
Antiguo 14/06/2007, 13:57
Avatar de abrahamvj  
Fecha de Ingreso: julio-2006
Ubicación: Lima, Peru
Mensajes: 708
Antigüedad: 17 años, 9 meses
Puntos: 18
Re: Alinear texto de word con codigo Visual Basic

Si, lo acabo de ver, dice algo asi como que "por unas horas" no habra servicio gratutito. yo espero, no hay problema

Abraham
  #9 (permalink)  
Antiguo 14/06/2007, 14:54
 
Fecha de Ingreso: junio-2007
Mensajes: 5
Antigüedad: 16 años, 10 meses
Puntos: 0
Re: Alinear texto de word con codigo Visual Basic

Si me das un mail te lo mando ahi es q no se como pasartelo
  #10 (permalink)  
Antiguo 15/06/2007, 13:07
Avatar de abrahamvj  
Fecha de Ingreso: julio-2006
Ubicación: Lima, Peru
Mensajes: 708
Antigüedad: 17 años, 9 meses
Puntos: 18
Re: Alinear texto de word con codigo Visual Basic

[email protected]

Abraham
Atención: Estás leyendo un tema que no tiene actividad desde hace más de 6 MESES, te recomendamos abrir un Nuevo tema en lugar de responder al actual.
Respuesta




La zona horaria es GMT -6. Ahora son las 18:23.