Export Access Object to Excel ,PDF, RTF , etc. using DoCmd.OutputTo
Microsoft Access allows us to export access object like table, query ,etc to other formats like Excel, PDF, RTF , etc. Using “DoCmd.OutputTo”
To know about DoCmd.OutputTo visit the below link
http://msdn.microsoft.com/en-us/library/aa141534(v=office.10).aspx
Syntax
DoCmd.outputto ObjectType, ObjectName, OutputFormat, Output file, Autostart, Templatefile, encoding,
ObjectType – acOutputTable( to output table), acOutputquery(to output query),acoutputreport(to output report),ascendform(to output form), acOutputModule(to output module)
http://msdn.microsoft.com/en-us/library/aa141534(v=office.10).aspx
Syntax
DoCmd.outputto ObjectType, ObjectName, OutputFormat, Output file, Autostart, Templatefile, encoding,
ObjectType – acOutputTable( to output table), acOutputquery(to output query),acoutputreport(to output report),ascendform(to output form), acOutputModule(to output module)
ObjectName – Name of table, query, Report etc.
OutputFormat – acFormatHTML ,acFormatRTF ,acFormatSNP,acFormatTXT ,acFormatXLS, acFormatXLSX , acFormatPDF , etc.
Output file – Complete path of output file eg. C:\abc.xls or d:\abc.pdf Keep it blank if you want to save at run time.
AutoStart Optional Variant
Templatefile – The full name, including the path, of the file to use as a template for an HTML file
Encoding- Optional Variant
Output file – Complete path of output file eg. C:\abc.xls or d:\abc.pdf Keep it blank if you want to save at run time.
AutoStart Optional Variant
Templatefile – The full name, including the path, of the file to use as a template for an HTML file
Encoding- Optional Variant
If you are facing any problem in export access report to excel visit the below linkhttp://support.microsoft.com/kb/934833
‘ EXAMPLE 1 EXPORT form TO xls FORMAT
Sub send_form_to_xls_using_docmd_outputto()
DoCmd.OutputTo acOutputForm, “sales_detail”, acFormatXLS, , True
End Sub
Sub send_form_to_xls_using_docmd_outputto()
DoCmd.OutputTo acOutputForm, “sales_detail”, acFormatXLS, , True
End Sub
‘ EXAMPLE 2 EXPORT form TO rtf FORMAT
Sub send_form_to_rtf_using_docmd_outputto()
DoCmd.OutputTo acOutputForm, “sales_detail”, acFormatRTF, , True
End Sub
Sub send_form_to_rtf_using_docmd_outputto()
DoCmd.OutputTo acOutputForm, “sales_detail”, acFormatRTF, , True
End Sub
‘ EXAMPLE 3 EXPORT TABLE TO RTF FORMAT
Sub send_table_to_RTF_using_docmd_outputto()
DoCmd.OutputTo acOutputTable, “sales_detail”, acFormatRTF, , True
End Sub
Sub send_table_to_RTF_using_docmd_outputto()
DoCmd.OutputTo acOutputTable, “sales_detail”, acFormatRTF, , True
End Sub
‘ EXAMPLE 4 EXPORT TABLE TO EXCEL FORMAT
Sub send_table_to_excel_using_docmd_outputto()
DoCmd.OutputTo acOutputTable, “sales_detail”, acFormatXLS, , True
End Sub
Sub send_table_to_excel_using_docmd_outputto()
DoCmd.OutputTo acOutputTable, “sales_detail”, acFormatXLS, , True
End Sub
‘ EXAMPLE 5 EXPORT TABLE TO EXCEL FORMAT
Sub send_table_to_PDF_using_docmd_outputto()
DoCmd.OutputTo acOutputTable, “sales_detail”, acFormatPDF, , True
End Sub
Sub send_table_to_PDF_using_docmd_outputto()
DoCmd.OutputTo acOutputTable, “sales_detail”, acFormatPDF, , True
End Sub
‘EXAMPLE 6
Sub export_report_to_rtf()
Dim rptname As String
rptname = “rep_name_a”
‘in rtf format
DoCmd.OutputTo acOutputReport, rptname, acFormatRTF, , True
End Sub
Sub export_report_to_rtf()
Dim rptname As String
rptname = “rep_name_a”
‘in rtf format
DoCmd.OutputTo acOutputReport, rptname, acFormatRTF, , True
End Sub
‘ EXAMPLE 7
Sub export_report_to_pdf()
Dim rptname As String
rptname = “rep_name_a”
‘in pdf format
DoCmd.OutputTo acOutputReport, rptname, acFormatPDF, , True
End Sub
Sub export_report_to_pdf()
Dim rptname As String
rptname = “rep_name_a”
‘in pdf format
DoCmd.OutputTo acOutputReport, rptname, acFormatPDF, , True
End Sub
Comments
Post a Comment