vba Microsoft Office Access 数据库引擎找不到对象
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/11132055/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
Microsoft office Access database engine could not find the object
提问by shanmugamgsn
I created a test MS Access DB to export a table to Excel and a text file.
我创建了一个测试 MS Access DB 来导出一个表格到 Excel 和一个文本文件。
This works for Excel:
这适用于 Excel:
DoCmd.OutputTo acOutputQuery, "QryExportToExcel", _
acFormatXLS, XFile, False
For the text file, I created a specification and used this code
对于文本文件,我创建了一个规范并使用了这个代码
DoCmd.TransferText acExportDelim, "Mytable Import Specification", "mytable", "D:\myfolder\test1.txt", False
In the error message, I get "test1#txt".
在错误消息中,我收到"test1#txt"。
The Microsoft Office Access database engine could not find the object
"test1#txt". Make sure the object exists and that you spell its name
and the path name correctly.
Microsoft Office Access 数据库引擎找不到对象
“test1#txt”。确保该对象存在并且您
正确拼写了它的名称和路径名。
I tried creating test1.txt in the same path. To my surprise, this deleted the file which is already present.
我尝试在同一路径中创建 test1.txt。令我惊讶的是,这删除了已经存在的文件。
Software: MS ACCESS 2007
软件:MS ACCESS 2007
回答by Heinzi
The Microsoft Office Access databasse engine could not find the object "test1#txt". Make sure the object exists and that you spell its name and path name correctly.
Microsoft Office Access 数据库引擎找不到对象“test1#txt”。确保该对象存在并且您正确拼写了它的名称和路径名。
This is a generic (and rather useless) error message that Access outputs in case anythinggoes wrong. One example would be a misspelled field name in the import/export specification.
这是 Access 输出的通用(而且相当无用)错误消息,以防出现任何问题。一个示例是导入/导出规范中拼写错误的字段名称。
You can get the "real" error message by trying the import operation "manually" in the Access user interface (rather than through code).
您可以通过在 Access 用户界面中“手动”尝试导入操作(而不是通过代码)来获取“真实”的错误消息。
回答by HansUp
The question author reported the problem was "because I was using an Import Specification for Exporting a file."
问题作者报告的问题是“因为我使用了导出文件的导入规范”。
They resolved the problem by using an Export Specification.
他们通过使用导出规范解决了这个问题。
回答by BMcDowell
I was having a similar situation and found that a file schema.iniwas in the destination folder. This was created when an acExportMerge was performed previously and it caused this error. Make sure that file has been deleted prior to executing a new TransferText.
我遇到了类似的情况,发现文件schema.ini在目标文件夹中。这是在之前执行 acExportMerge 时创建的,它导致了此错误。确保在执行新的 TransferText 之前已删除该文件。
回答by EastOfJupiter
Because you are doing DoCmd.TransferText, Access is expecting that the file Test1.txt exists in that location. Try creating the file first, and then do a transfer of the text.
因为您正在执行 DoCmd.TransferText,所以 Access 期望文件 Test1.txt 存在于该位置。尝试先创建文件,然后进行文本传输。
You can try this code before the export to create the file:
您可以在导出之前尝试此代码以创建文件:
Public Sub CreateExportFile()
Dim strFileName As String
Dim SomeStringToOutput
strFileName = "d:\myfolder\test1.txt"
Open strFileName For Output As #1
End Sub