Ver Mensaje Individual
  #9 (permalink)  
Antiguo 14/04/2008, 11:42
Foxi
 
Fecha de Ingreso: marzo-2008
Mensajes: 35
Antigüedad: 17 años
Puntos: 0
Re: Copiar y pegar todo el texto de un Word a otro mediante visual basic 6.0

Es un poco raro lo que entiendo que intentas, pero aún así no me rindo... A ver esto:

Para cualquier otro usuario: Añadir la referencia "Microsoft Word 11.0 Object Library" o similar...

Código:
Private Sub Form_Load()
Dim Documento As New Word.Application
Dim indice As Integer
    
    With Documento
        
        For indice = 1 To 2
            'abre un documento
            Call .Application.Documents.Open("c:\ejemplo" & CStr(indice) & ".doc")
            
            ' Establecemos la cabecera con un índice.
            If (EstablecerCabecera(indice, Documento) = True) Then
                ' Ok.
            End If
            
            ' Salvar y cerrar.
            .Application.Documents.Save
            .Application.Documents.Close
        Next
        
    End With
    Set Documento = Nothing
    
End Sub
Esto llamará a la siguiente función que igual te sirve:

Código:
Private Function EstablecerCabecera(ByVal v_nNumCuestionario As Integer, _
        ByRef r_Doc As Word.Application) As Boolean
    
    EstablecerCabecera = False
    On Error GoTo ERROR_FUNC
    
    With r_Doc
        
        ' Vista de la cabecera.
        .ActiveWindow.ActivePane.View.SeekView = wdSeekCurrentPageHeader
        
        ' Para alinear el texto a la derecha
        .Selection.ParagraphFormat.Alignment = wdAlignParagraphRight
        
        ' Fuente.
        .Selection.Font.Name = "Times News Roman"
        .Selection.Font.Size = 11
        
        ' Página dinámica y Cuestionario...
        .Application.Selection.TypeText "Página "
        .Selection.Fields.Add Range:=.Selection.Range, Type:=wdFieldPage
        .Application.Selection.TypeText vbNewLine
        .Application.Selection.TypeText "Cuestionario " & CStr(v_nNumCuestionario)
        
        ' Vista del documento.
        .ActiveWindow.ActivePane.View.SeekView = wdSeekMainDocument
        
        'mostramos documento
        .Application.Visible = True
        
    End With
    
    EstablecerCabecera = True
    
    Exit Function
    
ERROR_FUNC:
    Call MsgBox("Error: " & Err.Description)
End Function
Lo que hago es abrir dos documentos Word "c:\ejemplo1.doc" y "c:\ejemplo2.doc", a los cuales les asigno el número de página automático y un número de cuestionario i ==> Siendo i = 1 para el primer doc...

Aprovecha el código... Saludos, Foxi.

PD: Lo del icono "#" no era referido al caracter "#", pero ya irás aprendiendo a medida que utilices el foro... Además de las Caritas, intenta usar negritas y dar formatos, y puede que te acerces a lo que me refiero...