Access-Word
Publicado por Rafi (71 intervenciones) el 11/11/2009 14:18:20
Hol a todos, quisiera saber si me podeis ayudar a implementaren este código que lleva los datos de un formulario de access auna plantilla de documentos de word. Yo quiero que en vez de a una sola plantilla, se pueda enviar los datos a varias, esdecir a la que yo escoja. Gracias de antemano. Os pego el código que dicho se a de paso lo encontré en esta web.
Option Compare Database
Const strDOT = "Registro.dot"
Const strDOC = "RMS.doc"
Private Sub Comando26_Click()
Dim strPATH, strPROP
Dim WordApp As Object
strPATH = Application.CurrentProject.Path
Set WordApp = CreateObject("Word.Application")
With WordApp
.Visible = False
.Documents.Add strPATH & "\" & strDOT
End With
With WordApp.ActiveDocument
For Each strPROP In .CustomDocumentProperties
Select Case strPROP.Name
Case "DAD1": strPROP.Value = Nz(Me.DAD1, " ")
Case "DAD2": strPROP.Value = Format(DAD2, "dd/mm/yyyy")
Case "DAD3": strPROP.Value = Nz(Me.DAD3, " ")
Case "DAD4": strPROP.Value = Nz(Me.DAD4, " ")
Case "DAD5": strPROP.Value = Nz(Me.DAD5, " ")
Case "DAD6": strPROP.Value = Nz(Me.DAD6, " ")
Case "DAD7": strPROP.Value = Nz(Me.DAD7, " ")
Case "Otro": strPROP.Value = Nz(Me.Otro, " ")
End Select
'Tambien se puede hacer con
'strPROP.Value = Me(strPROP.Name)
Next
End With
With WordApp
.ActiveDocument.Fields.Update
.ActiveDocument.SaveAs strPATH & "\" & strDOC
.Quit
End With
Set WordApp = Nothing
MsgBox "DOCUMENTO LISTO PARA VISUALIZAR, NO OLVIDE REPASAR"
End Sub
Private Sub Comando27_Click()
Dim strPATH
Dim appWord As Object
strPATH = Application.CurrentProject.Path
Set appWord = CreateObject("Word.basic")
With appWord
.appmaximize
.fileopen strPATH & "\" & strDOC
.viewpage
End With
Set appWord = Nothing
DoCmd.Close
End Sub
Option Compare Database
Const strDOT = "Registro.dot"
Const strDOC = "RMS.doc"
Private Sub Comando26_Click()
Dim strPATH, strPROP
Dim WordApp As Object
strPATH = Application.CurrentProject.Path
Set WordApp = CreateObject("Word.Application")
With WordApp
.Visible = False
.Documents.Add strPATH & "\" & strDOT
End With
With WordApp.ActiveDocument
For Each strPROP In .CustomDocumentProperties
Select Case strPROP.Name
Case "DAD1": strPROP.Value = Nz(Me.DAD1, " ")
Case "DAD2": strPROP.Value = Format(DAD2, "dd/mm/yyyy")
Case "DAD3": strPROP.Value = Nz(Me.DAD3, " ")
Case "DAD4": strPROP.Value = Nz(Me.DAD4, " ")
Case "DAD5": strPROP.Value = Nz(Me.DAD5, " ")
Case "DAD6": strPROP.Value = Nz(Me.DAD6, " ")
Case "DAD7": strPROP.Value = Nz(Me.DAD7, " ")
Case "Otro": strPROP.Value = Nz(Me.Otro, " ")
End Select
'Tambien se puede hacer con
'strPROP.Value = Me(strPROP.Name)
Next
End With
With WordApp
.ActiveDocument.Fields.Update
.ActiveDocument.SaveAs strPATH & "\" & strDOC
.Quit
End With
Set WordApp = Nothing
MsgBox "DOCUMENTO LISTO PARA VISUALIZAR, NO OLVIDE REPASAR"
End Sub
Private Sub Comando27_Click()
Dim strPATH
Dim appWord As Object
strPATH = Application.CurrentProject.Path
Set appWord = CreateObject("Word.basic")
With appWord
.appmaximize
.fileopen strPATH & "\" & strDOC
.viewpage
End With
Set appWord = Nothing
DoCmd.Close
End Sub
Valora esta pregunta
0