access的outputto函数

outputout命令

Docmd.OutputTo(ObjectType, ObjectName, OutputFormat, OutputFile, AutoStart, TemplateFile,Encoding)

ObjectType 被输出对象的类型(表、查询还是窗体等……)

expression     必需。返回 DoCmd 对象的表达式。

acOutputForm
acOutputFunction
acOutputModule
acOutputQuery
acOutputReport
acOutputServerView
acOutputStoredProcedure
acOutputTable
acFormatASP
acFormatDAP
acFormatHTML
acFormatIIS
acFormatRTF
acFormatSNP
acFormatTXT
acFormatXLS
 
如果想导出成97-2003格式用 acSpreadsheetTypeExcel9
OutputFile 要输出文件的路径和完整名称。如果将该参数留空,Access 将提示指定输出文件名
AutoStart 逻辑值ture or false,导出时是否启动程序。例如,导出成xls时,是否启动excel。
TemplateFile 调用模版的路径和完整的名称。
需要注意的是导出时如果取消,ACCESS会报错,所以代码中需要加一段出错处理,一般这种错误的代码是2501.
示例:
Private Sub Command_Click()
 On Error GoTo err_Command_Click

DoCmd.OutputTo

acOutputTable, “Employees”,acFormatRTF, “D:\Employee.rtf”, True
err_Command_Click:

If Err.Number = 2501 Then Cancel = True

Exit Sub

版权声明:
作者:水东柳
链接:https://shuidl.com/1520.html
来源:水东柳博客
文章版权归作者所有,未经允许请勿转载。

THE END
分享
二维码
打赏
< <上一篇
下一篇>>