Bom dia, montei um BD nele contem 22 campos para preencher, quero importar eles para um docx, por indicador só consigo importar 10 campos, estou fazendo alguma coisa errada? Motivo de usar marcadores é que pretendo imprimir direto do BD, sem ter que acessar o docx.
Abaixo o código que usei, mas não está com todos os campos do BD. Espero uma ajuda.
Private Sub btnWord_Click()
Dim rsCli As Recordset, rspra As Recordset
Dim strCaminho As String
Dim oApp As Object
Set oApp = CreateObject("Word.Application")
With oApp
.Visible = True
.Documents.Open CurrentProject.Path & "\teste.docx"
.ActiveDocument.Bookmarks("numOficio").Select
.Selection.Text = Trim(CStr(Me.numOficio))
.ActiveDocument.Bookmarks("data").Select
.Selection.Text = Trim(CStr(Me.data))
.ActiveDocument.Bookmarks("funcionario").Select
.Selection.Text = Trim(CStr(Me.funcionario))
.ActiveDocument.Bookmarks("nome").Select
.Selection.Text = Trim(CStr(Me.nome))
.ActiveDocument.Bookmarks("matricula").Select
.Selection.Text = Trim(CStr(Me.matricula))
.ActiveDocument.Bookmarks("filiaçao").Select
.Selection.Text = Trim(CStr(Me.filiaçao))
.ActiveDocument.Bookmarks("rg").Select
.Selection.Text = Trim(CStr(Me.rg))
.ActiveDocument.Bookmarks("condenaçao").Select
.Selection.Text = Trim(CStr(Me.condenaçao))
.ActiveDocument.Bookmarks("artigo").Select
.Selection.Text = Trim(CStr(Me.artigo))
.ActiveDocument.Bookmarks("disciplina").Select
.Selection.Text = Trim(CStr(Me.disciplina))
.ActiveDocument.Bookmarks("geral").Select
.Selection.Text = Trim(CStr(Me.geral))
.ActiveDocument.SaveAs CurrentProject.Path & "\Capa_Prontuario\" & Format(Me.matricula) & ".docx"
strCaminho = CurrentProject.Path & "\Capa_Prontuario\" & Format(Me.matricula) & ".docx"
If Me.selImprimir.Value = -1 Then
.ActiveDocument.PrintOut
End If
End With
End Sub
Abaixo o código que usei, mas não está com todos os campos do BD. Espero uma ajuda.
Private Sub btnWord_Click()
Dim rsCli As Recordset, rspra As Recordset
Dim strCaminho As String
Dim oApp As Object
Set oApp = CreateObject("Word.Application")
With oApp
.Visible = True
.Documents.Open CurrentProject.Path & "\teste.docx"
.ActiveDocument.Bookmarks("numOficio").Select
.Selection.Text = Trim(CStr(Me.numOficio))
.ActiveDocument.Bookmarks("data").Select
.Selection.Text = Trim(CStr(Me.data))
.ActiveDocument.Bookmarks("funcionario").Select
.Selection.Text = Trim(CStr(Me.funcionario))
.ActiveDocument.Bookmarks("nome").Select
.Selection.Text = Trim(CStr(Me.nome))
.ActiveDocument.Bookmarks("matricula").Select
.Selection.Text = Trim(CStr(Me.matricula))
.ActiveDocument.Bookmarks("filiaçao").Select
.Selection.Text = Trim(CStr(Me.filiaçao))
.ActiveDocument.Bookmarks("rg").Select
.Selection.Text = Trim(CStr(Me.rg))
.ActiveDocument.Bookmarks("condenaçao").Select
.Selection.Text = Trim(CStr(Me.condenaçao))
.ActiveDocument.Bookmarks("artigo").Select
.Selection.Text = Trim(CStr(Me.artigo))
.ActiveDocument.Bookmarks("disciplina").Select
.Selection.Text = Trim(CStr(Me.disciplina))
.ActiveDocument.Bookmarks("geral").Select
.Selection.Text = Trim(CStr(Me.geral))
.ActiveDocument.SaveAs CurrentProject.Path & "\Capa_Prontuario\" & Format(Me.matricula) & ".docx"
strCaminho = CurrentProject.Path & "\Capa_Prontuario\" & Format(Me.matricula) & ".docx"
If Me.selImprimir.Value = -1 Then
.ActiveDocument.PrintOut
End If
End With
End Sub