vba 以编程方式导入 Excel 数据以访问具有列映射的表

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/5074888/
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

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-09-11 12:42:33  来源:igfitidea点击:

Import Excel Data programmatically to access table with column mapping

ms-accessvbaexcel-vbaexcel

提问by Jobin

I am in search of a tool / VBA code snippet that can port my excel data to my access table with effective columns mapping. Anybody please share if you have any idea on these.

我正在寻找一个工具/VBA 代码片段,它可以将我的 excel 数据通过有效的列映射移植到我的访问表中。如果您对这些有任何想法,请分享。

Thanks in advance

提前致谢

回答by Fionnuala

The standard way to import or link Excel in Access is to use the TransferSpreadsheet method of the DoCmd object. The link is for 2007, but it has been available certainly since 2000, if not before. TransferSpreadsheet includes a HasFieldNamesargument.

在 Access 中导入或链接 Excel 的标准方法是使用DoCmd 对象TransferSpreadsheet 方法。该链接适用于 2007 年,但自 2000 年以来肯定已经可用,如果不是更早的话。TransferSpreadsheet 包含一个HasFieldNames参数。

回答by chris neilsen

In Access 2007 you can use External Data/Import/Excel

在 Access 2007 中,您可以使用 External Data/Import/Excel

Just follow the wizard to select the workbook, type of connection, sheet and data. Data can be imported to a new table, appended to an existing table, or as a linked table

只需按照向导选择工作簿、连接类型、工作表和数据。数据可以导入到新表、附加到现有表或作为链接表

In Access 2003 its File/Get External Data/Importor File/Get External Data/Link tablesselect file type .xls and browse to the workbook

在 Access 2003 中File/Get External Data/ImportFile/Get External Data/Link tables选择文件类型 .xls 并浏览到工作簿

回答by Nathaniel_613

if this task is something that u need to perform on a regular basis, you may want to consider creating a macro and scheduled task to perform this automatically. it is very easy to settup and I can outline procedure if need be

如果您需要定期执行此任务,您可能需要考虑创建一个宏和计划任务来自动执行此任务。设置非常容易,如果需要,我可以概述程序