Buenas a todos, estoy intentando pasar unos campos de 2 formularios distintos en access a una plantilla de word, pero solo me pasa los campos del formulario actual(sobre el que tengo el boton), los del otro formulario el codigo me da error. Os paso el codigo.
Private Sub Comando45_Click()
Const plantilla = "\Factura.dot"
Dim appWord As Word.Application
Dim wordDoc As Word.Document
Set appWord = New Word.Application
With appWord
.Visible = True
.WindowState = wdWindowStateMaximize
End With
Set wordDoc = appWord.Documents.Add(CurrentProject.Path & plantilla)
With wordDoc
.Unprotect
.Bookmarks("Nombre_ase").Range.Text = Me.[Factura].Form!Nombre_ase
.Bookmarks("Direccion_ase").Range.Text = Me.[Factura].Form!Direccion_ase
.Bookmarks("Codigo_postal_ase").Range.Text = Me.[Factura].Form!Codigo_postal_ase
.Bookmarks("Poblacion_ase").Range.Text = Me.[Factura].Form!Poblacion_ase
.Bookmarks("Provincia_ase").Range.Text = Me.[Factura].Form!Provincia_ase
.Bookmarks("CIF_ase").Range.Text = Me.[Factura].Form!CIF_ase
.Bookmarks("Nombre_tra").Range.Text = Me.Nombre_tra.Value
.Bookmarks("Apellido1_tra").Range.Text = Me.Apellido1_tra.Value
.Bookmarks("Apellido2_tra").Range.Text = Me.Apellido2_tra.Value
.Bookmarks("Dni_tra").Range.Text = Me.Dni_tra.Value
.Bookmarks("Direccion_tra").Range.Text = Me.Direccion_tra.Value
.Bookmarks("Poblacion_tra").Range.Text = Me.Poblacion_tra.Value
.Bookmarks("Provincia_tra").Range.Text = Me.Provincia_tra.Value
.Protect Type:=wdAllowOnlyFormFields, NoReset:=True
End With
Set appWord = Nothing
Set wordDoc = Nothing
End Sub
Leer las respuestas