标签:
accessexcel导出 |
分类: 计算机应用 |
可以用宏做,也可以用代码,用宏就是outputout,
代码也是,具体如下:
Docmd.OutputTo(ObjectType, ObjectName, OutputFormat, OutputFile,
AutoStart, TemplateFile,
Encoding)
ObjectType 被输出对象的类型(表、查询还是窗体等……)
| acOutputForm |
| acOutputFunction |
| acOutputModule |
| acOutputQuery |
| acOutputReport |
| acOutputServerView |
| acOutputStoredProcedure |
| acOutputTable |
ObjectName 被输出对象的名字
OutputFormat 输出的格式
| acFormatASP |
| acFormatDAP |
| acFormatHTML |
| acFormatIIS |
| acFormatRTF |
| acFormatSNP |
| acFormatTXT |
| acFormatXLS |
OutputFile 要输出文件的路径和完整名称。如果将该参数留空,Access
将提示指定输出文件名
AutoStart 逻辑值ture or
false,导出时是否启动程序。例如,导出成xls时,是否启动excel。
TemplateFile
调用模版的路径和完整的名称。
需要注意的是导出时如果取消,ACCESS会报错,所以代码中需要加一段出错处理,一般这种错误的代码是2501.
示例:
Private Sub
Command_Click()On Error GoTo
err_Command_ClickDoCmd.OutputToacOutputTable,
"Employees",acFormatRTF, "D:\Employee.rtf",
Trueerr_Command_Click:If Err.Number = 2501
Then Cancel = True
Exit
Sub
加载中…