努力编写代码以将文件夹中的所有文件导入Access表 [英] Struggling to write code to import all files in a folder to an Access Table

查看:217
本文介绍了努力编写代码以将文件夹中的所有文件导入Access表的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

您好,


我用几年前建立的数据库有一个宏,使用VBA导入文件夹中的所有文本文件(C:\ Data \ Reports \Inventory Reports)到Access中的表(Aeppays Daily Consolidated)。我创建了一个规范(DailyAeppayImport)来导入文件作为分隔,它完美地工作。在我的公司重建配置文件后,我不再拥有数据库,并且现在在网上搜索有关如何重新创建此代码的帮助。任何帮助都将非常感激。它只需要导入所有文本文件(例如名称:AADMIN-863826.AEPPAYS-HOLDRPT-PASS-FWD.20170616020528.txt),其名称每天更改为Access中的单个表。

Hello,

I use to have a database I built several years ago that had a macro using VBA to import all text files in a folder (C:\Data\Reports\Inventory Reports) to a table in Access (Aeppays Daily Consolidated). I had a specification created (DailyAeppayImport) to import the files as delimited and it worked perfectly. After a profile rebuild by my company, I no longer have the database and have struggled now searching online for help as to how I can recreate this code. Any help at all would be greatly appreciated. It just needs to import all the text files (example name: AADMIN-863826.AEPPAYS-HOLDRPT-PASS-FWD.20170616020528.txt) whose names change daily into a single table in Access.

推荐答案

为了便于论证,我们假设所有的文本文件都在名为Test的文件夹中,即C:\ Test \ * .txt。我们还假设您之前已经定义了导入规范并将其命名为My Import Specs。此规范将C:\Test \文件夹中所有文本文件中的所有数据附加到名为tblResults的表中。用于检索C:\ Test \中的所有文本文件并使用我的导入规范规范将其内容附加到tblResults的代码是:
For the sake of argument, let''s assume that all of your Text Files are in a Folder named Test, namely C:\Test\*.txt. Let''s also assume that you previously have defined your Import Specifications and named it My Import Specs. This specification will append all Data within all Text Files in the C:\Test\ Folder to a Table named tblResults. The Code to retrieve all Text Files in C:\Test\ and append their contents to tblResults using My Import Specs Specification is:
展开 | 选择 | 换行 | 行号


这听起来很不幸。也许这是一个愚蠢的问题,但你是否曾尝试过询问他们是否有旧版资料的备份等?不得不从头开始重新创建可能会成为很多工作。真的很沮丧地回到你开始的地方。
That sounds very unfortunate. Maybe a silly question, but have you tried asking IT if they have backups of your old profile etc? Having to recreate from scratch could turn out to be a lot of work. Frustrating purely to arrive back at where you started.


告诉我这件事,这是一条令人难以置信的令人沮丧的道路。
Yeah tell me about it, it has been an incredibly frustrating path to go down.


这篇关于努力编写代码以将文件夹中的所有文件导入Access表的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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