Ver Mensaje Individual
  #5 (permalink)  
Antiguo 02/04/2008, 09:11
iaras66
 
Fecha de Ingreso: octubre-2007
Mensajes: 36
Antigüedad: 17 años, 6 meses
Puntos: 0
Re: Mediante V.B 6.0 introducir en el encabezado de un Word texto

Hola Foxi!!!

He añadido esta parte del código, y me da un error de que falla el comando... no se si puede ser por que hay que añadir alguna librería, pero me da que el problema está en el "activewindow".

Teniendo en cuenta que mi código hace que se abra y se muestren los datos en el word en el form load puede que eso de problemas... no lo se!!!

La parte de código por lo pronto me queda así: (aquì hago que funcione con un buttom en vez del form_load)

Private Sub Command1_Click()
Dim Documento As New Word.Application

With Documento
'abre un documento
.Application.Documents.Open App.Path & "\ejemplo.doc"


'final del documento
.Application.Selection.EndKey wdStory
'intro
.Application.Selection.TypeParagraph
'introduccion de texto



'Activar el encabezado
.ActiveWindow.ActivePane.View.SeekView = wdSeekCurrentPageHeader
'Alinear el texto a la derecha en el encabezado
.Selection.ParagraphFormat.Alignment = wdAlignParagraphRight

.Application.Selection.TypeText "Nº Cuestionario:" + vbNewLine + "Nº Página:"
.Selection.ParagraphFormat.Alignment = wdAlignParagraphRight
'intro
.Application.Selection.TypeParagraph
.Application.Selection.TypeParagraph
.Application.Selection.TypeParagraph
'crear tabla
.Documents.Item(1).Tables.Add Documento.Application.Selection.Range, 3, 5

Documento.Selection.Tables(1).Cell(1, 1).Borders(wdBorderTop).Visible = True
Documento.Selection.Tables(1).Cell(1, 1).Borders(wdBorderLeft).Visible = True
Documento.Selection.Tables(1).Cell(1, 1).Borders(wdBorderBottom).Visible = True
Documento.Selection.Tables(1).Cell(1, 1).Borders(wdBorderRight).Visible = True
Documento.Selection.Tables(1).Cell(1, 2).Borders(wdBorderTop).Visible = True
Documento.Selection.Tables(1).Cell(1, 2).Borders(wdBorderLeft).Visible = True
Documento.Selection.Tables(1).Cell(1, 2).Borders(wdBorderBottom).Visible = True
Documento.Selection.Tables(1).Cell(1, 2).Borders(wdBorderRight).Visible = True
Documento.Selection.Tables(1).Cell(2, 1).Borders(wdBorderTop).Visible = True
Documento.Selection.Tables(1).Cell(2, 1).Borders(wdBorderLeft).Visible = True
Documento.Selection.Tables(1).Cell(2, 1).Borders(wdBorderBottom).Visible = True
Documento.Selection.Tables(1).Cell(2, 1).Borders(wdBorderRight).Visible = True
Documento.Selection.Tables(1).Cell(2, 2).Borders(wdBorderTop).Visible = True
Documento.Selection.Tables(1).Cell(2, 2).Borders(wdBorderLeft).Visible = True
Documento.Selection.Tables(1).Cell(2, 2).Borders(wdBorderBottom).Visible = True
Documento.Selection.Tables(1).Cell(2, 2).Borders(wdBorderRight).Visible = True


'relleno de tabla
.Documents.Item(1).Tables(1).Cell(1, 1).Range.Text = "Nº Cuestionario"
.Documents.Item(1).Tables(1).Cell(2, 1).Range.Text = "Nº Página"
.Documents.Item(1).Tables(1).Cell(1, 2).Range.Text = numinicio
.Documents.Item(1).Tables(1).Cell(2, 2).Range.Text = numpaginas

'mostramos documento
.Application.Visible = True
End With
Set Documento = Nothing
End Sub

Como puedes ver intento pasarlo bien poniendolo como campos de texto y bien probando a pasr los datos en una tabla (esta solución me interesa más).

Así que dos preguntas:
1- Como podría alinear la tabla a un lado u otro del documento??
2- Necesito agregar alguna librería para la parte de código de el encabezado???