Bom dia Amigos,
Estou usando o código abaixo para criar um arquivo no word. Minha dúvida é a seguinte, depois do arquivo gerado, existe a possibilidade de exportá-lo ou salvá-lo diretamente no formato PDF?
Grato
Private Sub btnOk_Click()
Dim rsborderô As DAO.Recordset
Dim strsql As String
Dim Banco As String
Dim Agência As String
Dim conta As String
Banco = Me.NomeBanco
Agência = Me.Agência
conta = Me.ContaCorrente
Dim DocWord As Object
Set DocWord = CreateObject("Word.Application")
With DocWord
.visible = False
.Documents.Add Template:=CurrentProject.Path & "\TED.doc", NewTemplate:=False, DocumentType:=0
'============================================================================================================
strsql = "SELECT * FROM tblBorderôs WHERE X = " & [Forms]![frmDocumentos].[X] & " AND dtBorderô = #" & Format([Forms]![frmDocumentos].[DtBorderô], "mm/dd/yyyy") & "# AND Cliente = '" & [Forms]![frmDocumentos].[Cliente] & "'"
Set rsborderô = CurrentDb.OpenRecordset(strsql)
.ActiveDocument.Bookmarks("dtBorderô").Select
.Selection.Text = Format(rsborderô!DtBorderô, "Long Date")
If rsborderô!Recompra > 0 Then
Dim vLíquido As Currency
Dim vExtenso As String
vLíquido = Format(Format(rsborderô!Líquido, "Currency") - Format(rsborderô!Recompra, "Currency"), "Currency")
vExtenso = Extenso(CDbl(vLíquido), "Reais", "Real")
.ActiveDocument.Bookmarks("valor").Select
.Selection.Text = Format(vLíquido, "Currency")
.ActiveDocument.Bookmarks("Extenso").Select
.Selection.Text = vExtenso
ElseIf vReembolso > 0 Then
vLíquido = Format(Format(rsborderô!Líquido, "Currency") + Format(rsborderô!Reembolso, "Currency"), "Currency")
vExtenso = Extenso(CDbl(vLíquido), "Reais", "Real")
.ActiveDocument.Bookmarks("valor").Select
.Selection.Text = Format(vLíquido, "Currency")
.ActiveDocument.Bookmarks("Extenso").Select
.Selection.Text = vExtenso
Else
vExtenso = Extenso(CDbl(rsborderô!Líquido), "Reais", "Real")
.ActiveDocument.Bookmarks("valor").Select
.Selection.Text = Format(rsborderô!Líquido, "Currency")
.ActiveDocument.Bookmarks("Extenso").Select
.Selection.Text = vExtenso
End If
.ActiveDocument.Bookmarks("Conta").Select
.Selection.Text = conta
.ActiveDocument.Bookmarks("Agência").Select
.Selection.Text = Agência
.ActiveDocument.Bookmarks("Banco").Select
.Selection.Text = Banco & Chr(32) & "(" & Me.Banco & ")"
.ActiveDocument.Bookmarks("Número").Select
.Selection.Text = Format([Forms]![frmDocumentos].[DtBorderô], "ddmmyy") & "-" & Format([Forms]![frmDocumentos].[X], "00")
.ActiveDocument.Bookmarks("RazãoSocial").Select
.Selection.Text = UCase([Forms]![frmDocumentos].[Razão])
'============================================================================================================
.ActiveDocument.SaveAs CurrentProject.Path & "\Cartas\" & "TED" & UCase([Forms]![frmDocumentos].[Cliente]) & Format([Forms]![frmDocumentos].[DtBorderô], "ddmmyy") & "-" & [Forms]![frmDocumentos].[X] & ".doc"
.ActiveDocument.Close
End With
DocWord.Quit
Set rsborderô = Nothing
Set DocWord = Nothing
DoCmd.OutputTo acOutputStoredProcedure
[Forms]![frmDocumentos].[Cliente] = Null
[Forms]![frmDocumentos].[DtBorderô] = Null
[Forms]![frmDocumentos].[X] = Null
DoCmd.Close acForm, "frmContasClientesOpt"
'Dim nArquivo As String
'nArquivo = CurrentProject.Path & "\Cartas\" & "TED" & UCase(Me.Cliente) & Format(Me.DtBorderô, "ddmmyy") & "-" & Me.X & ".doc"
'Call ShellExecute(0, vbNullString, nArquivo, vbNullString, vbNullString, 1)
End Sub
Estou usando o código abaixo para criar um arquivo no word. Minha dúvida é a seguinte, depois do arquivo gerado, existe a possibilidade de exportá-lo ou salvá-lo diretamente no formato PDF?
Grato
Private Sub btnOk_Click()
Dim rsborderô As DAO.Recordset
Dim strsql As String
Dim Banco As String
Dim Agência As String
Dim conta As String
Banco = Me.NomeBanco
Agência = Me.Agência
conta = Me.ContaCorrente
Dim DocWord As Object
Set DocWord = CreateObject("Word.Application")
With DocWord
.visible = False
.Documents.Add Template:=CurrentProject.Path & "\TED.doc", NewTemplate:=False, DocumentType:=0
'============================================================================================================
strsql = "SELECT * FROM tblBorderôs WHERE X = " & [Forms]![frmDocumentos].[X] & " AND dtBorderô = #" & Format([Forms]![frmDocumentos].[DtBorderô], "mm/dd/yyyy") & "# AND Cliente = '" & [Forms]![frmDocumentos].[Cliente] & "'"
Set rsborderô = CurrentDb.OpenRecordset(strsql)
.ActiveDocument.Bookmarks("dtBorderô").Select
.Selection.Text = Format(rsborderô!DtBorderô, "Long Date")
If rsborderô!Recompra > 0 Then
Dim vLíquido As Currency
Dim vExtenso As String
vLíquido = Format(Format(rsborderô!Líquido, "Currency") - Format(rsborderô!Recompra, "Currency"), "Currency")
vExtenso = Extenso(CDbl(vLíquido), "Reais", "Real")
.ActiveDocument.Bookmarks("valor").Select
.Selection.Text = Format(vLíquido, "Currency")
.ActiveDocument.Bookmarks("Extenso").Select
.Selection.Text = vExtenso
ElseIf vReembolso > 0 Then
vLíquido = Format(Format(rsborderô!Líquido, "Currency") + Format(rsborderô!Reembolso, "Currency"), "Currency")
vExtenso = Extenso(CDbl(vLíquido), "Reais", "Real")
.ActiveDocument.Bookmarks("valor").Select
.Selection.Text = Format(vLíquido, "Currency")
.ActiveDocument.Bookmarks("Extenso").Select
.Selection.Text = vExtenso
Else
vExtenso = Extenso(CDbl(rsborderô!Líquido), "Reais", "Real")
.ActiveDocument.Bookmarks("valor").Select
.Selection.Text = Format(rsborderô!Líquido, "Currency")
.ActiveDocument.Bookmarks("Extenso").Select
.Selection.Text = vExtenso
End If
.ActiveDocument.Bookmarks("Conta").Select
.Selection.Text = conta
.ActiveDocument.Bookmarks("Agência").Select
.Selection.Text = Agência
.ActiveDocument.Bookmarks("Banco").Select
.Selection.Text = Banco & Chr(32) & "(" & Me.Banco & ")"
.ActiveDocument.Bookmarks("Número").Select
.Selection.Text = Format([Forms]![frmDocumentos].[DtBorderô], "ddmmyy") & "-" & Format([Forms]![frmDocumentos].[X], "00")
.ActiveDocument.Bookmarks("RazãoSocial").Select
.Selection.Text = UCase([Forms]![frmDocumentos].[Razão])
'============================================================================================================
.ActiveDocument.SaveAs CurrentProject.Path & "\Cartas\" & "TED" & UCase([Forms]![frmDocumentos].[Cliente]) & Format([Forms]![frmDocumentos].[DtBorderô], "ddmmyy") & "-" & [Forms]![frmDocumentos].[X] & ".doc"
.ActiveDocument.Close
End With
DocWord.Quit
Set rsborderô = Nothing
Set DocWord = Nothing
DoCmd.OutputTo acOutputStoredProcedure
[Forms]![frmDocumentos].[Cliente] = Null
[Forms]![frmDocumentos].[DtBorderô] = Null
[Forms]![frmDocumentos].[X] = Null
DoCmd.Close acForm, "frmContasClientesOpt"
'Dim nArquivo As String
'nArquivo = CurrentProject.Path & "\Cartas\" & "TED" & UCase(Me.Cliente) & Format(Me.DtBorderô, "ddmmyy") & "-" & Me.X & ".doc"
'Call ShellExecute(0, vbNullString, nArquivo, vbNullString, vbNullString, 1)
End Sub