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
共有 0 条评论