Importing a text with separators

后端 未结 2 937
失恋的感觉
失恋的感觉 2020-12-19 06:01

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

The columns are separated using tabs (the TAB button). My question is,

2条回答
  •  情话喂你
    2020-12-19 06:28

    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.

    enter image description here

    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.

    enter image description here

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

    Now you can use in VBA like this

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

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

提交回复
热议问题