Obrigado Roberto
Private Sub ActiveReport_ReportStart()
Me.Toolbar.Tools.Add "Exportar"
Me.DataControl1.ConnectionString = "Provider=MSDASQL;Persist Security Info=True;Extended Properties=DBQ=" & App.Path & "AGENDA.mdb;DefaultDir=" & App.Path & ";Driver={Driver do Microsoft Access (*.mdb)};DriverId=25;FIL=MS Access;FILEDSN=" & App.Path & "access.dsn;MaxBufferSize=2048;MaxScanRows=8;PageTimeout=5;PWD=1j5a0c3a7r0e;SafeTransactions=0;Threads=3;UID=admin;UserCommitSync=Yes;"
Me.DataControl1.Source = "select * from taborca where ORCA_ORCA = " & Chr(39) & FrmOrcamento.Text2.Text & Chr(39)
Me.DataControl1.Refresh
End Sub
'Paste this code into the
Private Sub ActiveReport_ToolbarClick(ByVal Tool As DDActiveReports2.DDTool)
On Error GoTo EH
Dim PDF As ActiveReportsPDFExport.ARExportPDF
Dim RTF As ActiveReportsRTFExport.ARExportRTF
Dim XLS As ActiveReportsExcelExport.ARExportExcel
' Dim TXT As ActiveReportsTextExport.ARExportText
' Dim FrmOrcamento As fExport
Dim iMinPeriod As Integer
If Tool.Caption = "Exportar" Then
' Set FrmOrcamento = New fExport
FrmOrcamento.dlgCommon.FileName = "Exportar" & FrmOrcamento.Text2.Text
FrmOrcamento.dlgCommon.Filter = "Adobe Acrobat Format (*.pdf)|*.pdf|Rich Text Format (*.rtf)|*.rtf|Excel Format (*.xls)|*.xls"
FrmOrcamento.dlgCommon.CancelError = True
FrmOrcamento.dlgCommon.Flags = cdlOFNHideReadOnly + _
cdlOFNLongNames + cdlOFNPathMustExist
On Error Resume Next
FrmOrcamento.dlgCommon.ShowSave
'If user Cancelled, then error 32755 will be raised
If Err Then
Err.Clear
Exit Sub
End If
On Error GoTo EH
'If ther are two periods(.) in the filename, then display
'an error
iMinPeriod = InStr(FrmOrcamento.dlgCommon.FileName, ".")
If InStr(Mid(FrmOrcamento.dlgCommon.FileName, _
iMinPeriod + 1), ".") > 0 Then
Beep
MsgBox "Nome de Arquivo Inválido", vbOKOnly, _
"Messangem de Exportação"
Exit Sub
End If
Select Case True
Case UCase(Right$(Trim$(FrmOrcamento.dlgCommon.FileName), _
4)) = ".PDF"
Set PDF = New ActiveReportsPDFExport.ARExportPDF
PDF.FileName = FrmOrcamento.dlgCommon.FileName
Me.Export PDF
Beep
MsgBox "Seu relatório foi savado com sucesso com o nome de " & _
FrmOrcamento.dlgCommon.FileName, vbOKOnly, _
"Messangem de Exportação"
Case UCase(Right$(Trim$(FrmOrcamento.dlgCommon.FileName), _
4)) = ".RTF"
Set RTF = New ActiveReportsRTFExport.ARExportRTF
RTF.FileName = FrmOrcamento.dlgCommon.FileName
Me.Export RTF
Beep
MsgBox "Seu relatório foi savado com sucesso com o nome de " & _
FrmOrcamento.dlgCommon.FileName, vbOKOnly, _
"Messangem de Exportação"
Case UCase(Right$(Trim$(FrmOrcamento.dlgCommon.FileName), _
4)) = ".XLS"
Set XLS = New ActiveReportsExcelExport.ARExportExcel
XLS.FileName = FrmOrcamento.dlgCommon.FileName
Me.Export XLS
Beep
MsgBox "Seu relatório foi savado com sucesso com o nome de " & _
FrmOrcamento.dlgCommon.FileName, vbOKOnly, _
"Messangem de Exportação"
Case Else
Beep
MsgBox "Invalid File Name", vbOKOnly, _
"Messangem de Exportação"
Exit Sub
End Select
End If
Set PDF = Nothing
Set RTF = Nothing
Set XLS = Nothing
Set FrmOrcamento = Nothing
Exit Sub
EH:
Set PDF = Nothing
Set RTF = Nothing
Set XLS = Nothing
Set FrmOrcamento = Nothing
Screen.MousePointer = vbDefault
Beep
MsgBox Err.Description, vbOKOnly, "Error Message"
End Sub
Obrigado.