导入使用VBA分隔符的文本 [英] Importing a text with separators using VBA

查看:291
本文介绍了导入使用VBA分隔符的文本的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想实现自动化的新的txt文件的添加,至极都具有相同的(已知)的布局。

I am trying to automate the adding of new txt files , wich all have the same (known) layout.

中的列使用标签(标签按钮)分隔。是否有可能做到这一点在VBA就像在访问向导导入文本文件?

The columns are seperated using tabs (the TAB button). Is it possible to do this in VBA like in the Access wizard for importing text files?

我正在使用VBA的 DoCmd.TransferText 方法

I am using the DoCmd.TransferText method in VBA

推荐答案

您将需要经过一次向导,使您的规范文件。要做到这一点导入文本文件一样正常,但之前你太深入向导中点击左下角的高级按钮。这是你让你的spec文件。

You'll need to go through the wizard once to make your specification file. TO do this import your text file like normal but before you get too deep into the wizard click on the bottom left, the "Advanced..." button. This is where you make your spec file.

请LL这些列匹配输入文件,数据类型和所有。要确保,如果你使用的是一个选择 {选项卡} 字段分隔符及相应的文本识别符。

Make ll these columns match your input file, data types and all. Be sure to select the {tab} field delimiter and the appropriate text qualifier if you are using one.

保存规格(这可以在以后回来此相同的屏幕,单击编辑规格... 然后保存在你的旧)

Save your spec (which can later be edited by coming back to this same screen and clicking Specs... then saving over your old one)

现在您可以在VBA中使用这样

Now you can use in VBA like this

DoCmd.TransferText acImportDelim, "your spec name", "destination table name", sourceFilePath

有一个参数 HasFieldNames ,你必须决定,如果它是根据您的文件。

There is a parameter HasFieldNames that you'll have to decide if it is true or false based on your file.

这篇关于导入使用VBA分隔符的文本的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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