导出到excel时出现运行时错误2391 [英] Runtime error 2391 while exporting to excel

查看:514
本文介绍了导出到excel时出现运行时错误2391的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

各位大家好!我是处理访问的新手,我正在尝试将查询结果导出到现有的excel表。根据我在网上找到的其他例子,我想出了这段代码:

Hello everybody! I'm new at working with access, and i'm trying to export the result of a query to an already existing excel table. Following other examples I found online, I came up with this bit of code:

DoCmd.TransferSpreadsheet acExportq, 8, "Myquery", "Destination path", True, "Range"

我在表格中设置了一个范围,并将这行代码放在我表格中的一个按钮上。当我运行代码时,我得到一个运行时错误2931,通知我目标表'Myquery'中不存在字段F1。

I set a range in my table, and put this line of code on a button in my form. When I run the code, i get a Runtime error 2931 that informs me that field F1 does not exist in my destination table 'Myquery'.

有没有办法解决这个错误?我只找到了导入文件的例子,但没有关于导出的例子。

Is there a way to solve this error? I only found examples on importing files, but nothing on exporting.

顺便说一句,我正在使用access和excel 2016。

by the way, i'm using access and excel 2016.

谢谢任何人都可以帮助我!

Thanks to whomever can help me!

推荐答案

您好

当我读到它时你拼写了一些它错误。它不是"acExportq"它是"acExport"

As I read it you spelled some of it wrong. Its not "acExportq" it is "acExport"

然后要选择Excel版本,你应该输入"DoCmd.TransferSpreadsheet acExport,acSpreadsheetTypeExcel8""

Then to choose Excel version you should type "DoCmd.TransferSpreadsheet acExport, acSpreadsheetTypeExcel8"

下面是我的一个工作线:

Below is one of mine working lines:

DoCmd.TransferSpreadsheet acExport,acSpreadsheetTypeExcel12," MyQuery",PathToEXTAB,True," OurArticles"





这篇关于导出到excel时出现运行时错误2391的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆