Re: [问题] VBA读取TXT格式问题

楼主: aup65797 (有缘人)   2016-07-09 20:59:41
Sub test()
Dim qt As QueryTable
Set qt = ActiveSheet.QueryTables.Add("TEXT;d:\20160703.txt", [a1])
With qt
.AdjustColumnWidth = False
.TextFileParseType = xlDelimited
.TextFileTabDelimiter = True
.TextFileCommaDelimiter = True
.Refresh
End With
End Sub
用以上方式 , excel读取会空一格 , 麻烦大大
https://www.dropbox.com/s/4uxgfuykhl0h6ix/VBA%20TAB%20format.PNG?dl=0
作者: soyoso (我是耀宗)   2016-07-09 21:18:00
加上textfileconsecutivedelimiter=true 试试
作者: azteckcc ( )   2016-07-09 21:18:00
把你的 TXT 传上来,个人猜你的txt里可能会有状况,比如同时有分隔符同时有tab和逗号
楼主: aup65797 (有缘人)   2016-07-09 21:27:00
作者: soyoso (我是耀宗)   2016-07-09 21:41:00
测试上将连结内TextFileTabDelimiter改为true再加上回文第一笔的部分,应可https://imgur.com/LGBAe2D

Links booklink

Contact Us: admin [ a t ] ucptt.com