Foros del Web » Programación para mayores de 30 ;) » Programación General » Visual Basic clásico »

Insertar datos en Word mediante VB 6.0

Estas en el tema de Insertar datos en Word mediante VB 6.0 en el foro de Visual Basic clásico en Foros del Web. Hola!!! la parte del código que me abre el Word deseado me va bien pero a la hora de insertar los datos ahí no... me ...
  #1 (permalink)  
Antiguo 31/03/2008, 04:08
 
Fecha de Ingreso: octubre-2007
Mensajes: 36
Antigüedad: 16 años, 6 meses
Puntos: 0
Insertar datos en Word mediante VB 6.0

Hola!!! la parte del código que me abre el Word deseado me va bien pero a la hora de insertar los datos ahí no... me da un error de "Error 438, el objeto no admite esta propiedad o metodo (refiriendose a la variable oApp a la hora de asignarle la ruta del documento)" en la siguiente parte de código:

Private Sub Command1_Click()
Dim WordObj As New Word.Application
Dim paginas As Integer
Dim ruta As String
Dim oApp As Word.Document
Dim Doc As Word.Document

'Start a new document in Word
Me.CommonDialog1.ShowOpen
ruta = Me.CommonDialog1.FileName
Set oApp = WordObj.Documents.Open(ruta)
Set Doc = oApp.Documents.Add

Luego el código seguiría así:


With Doc.MailMerge

'Insert the mail merge fields temporarily so that
'you can use the range containing the merge fields as a layout
'for your labels -- to use this as a layout, you can add it
'as an AutoText entry.
With .Fields
.Application.Selection.TypeText "Nº Cuestionario"
oApp.Selection.TypeParagraph
.Add oApp.Selection.Range, "numinicio"
oApp.Selection.TypeParagraph
.Application.Selection.TypeText "Nº Cuestionario2"
oApp.Selection.TypeParagraph
.Add oApp.Selection.Range, "numfinal"
oApp.Selection.TypeParagraph
.Application.Selection.TypeText "Nº Página"
oApp.Selection.TypeParagraph
.Add oApp.Selection.Range, "numpagina"
oApp.Selection.TypeParagraph

End With
Dim oAutoText As Word.AutoTextEntry
Set oAutoText = oApp.NormalTemplate.AutoTextEntries.Add("MyLabelLa yout", oDoc.Content)
oDoc.Content.Delete 'Merge fields in document no longer needed now
'that the AutoText entry for the label layout
'has been added so delete it.

'Set up the mail merge type as mailing labels and use
'a tab-delimited text file as the data source.
.MainDocumentType = wdMailingLabels
.OpenDataSource Name:="C:\Proyecto\Data.accdb" 'Specify your data source here

'Create the new document for the labels using the AutoText entry
'you added -- 5160 is the label number to use for this sample.
'You can specify the label number you want to use for the output
'in the Name argument.
oApp.MailingLabel.CreateNewDocument Name:="5160", Address:="", _
AutoText:="MyLabelLayout", LaserTray:=wdPrinterManualFeed

'Execute the mail merge to generate the labels.
.Destination = wdSendToNewDocument
.Execute

'Delete the AutoText entry you added
oAutoText.Delete

End With

'Close the original document and make Word visible so that

'the mail merge results are displayed
oDoc.Close False
oApp.Visible = True

'Prevent save to Normal template when user exits Word
oApp.NormalTemplate.Saved = True

Como podría hacer para meter los datos en el documento elegido????
  #2 (permalink)  
Antiguo 31/03/2008, 05:22
 
Fecha de Ingreso: octubre-2007
Mensajes: 36
Antigüedad: 16 años, 6 meses
Puntos: 0
Re: Insertar datos en Word mediante VB 6.0

Bueno ya he logrado resolver el problema... ahora la pregunta sería como hacer para que esos datos se me reflejen en la parte derecha e izquierda del encabezado del Word; o en los margenes derecho e izquierdo del pie según elijamos nosotros mediante un buttom.

Alguien sabe como hacerlo???
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 02:04.