excel批量导入文本的程序我用VBA
可以试试单步运行,运行到strFiles获取到值以后,看看获取的值是什么
例如 strFiles = "1001161。txt" 那
With ActiveSheet。QueryTables。 Add(Connection:="TEXT;C:\Documents and Settings\Administrator\桌面\已转化蔡斯数据\1001161。txt", Destination:=Range("A1"))"
就可以写成
With ActiveSheet。 QueryTables。Add(Connection:="TEXT;C:\Documents and Settings\A...全部
可以试试单步运行,运行到strFiles获取到值以后,看看获取的值是什么
例如 strFiles = "1001161。txt" 那
With ActiveSheet。QueryTables。
Add(Connection:="TEXT;C:\Documents and Settings\Administrator\桌面\已转化蔡斯数据\1001161。txt", Destination:=Range("A1"))"
就可以写成
With ActiveSheet。
QueryTables。Add(Connection:="TEXT;C:\Documents and Settings\Administrator\桌面\已转化蔡斯数据\" & strFiles , Destination:=Range("A1"))"
而 。
Name = "1001161" 要复杂些
如果你获取的文件都是。txt的,就可以直接写
。Name = cstr(left(strFiles,len(strFiles)-4))
如果你获取的文件名都是。
tex,而且前面的名称都是同样的长度,就更简单
。Name = cstr(left(strFiles,7))
如果以上两个都不成立,那就要写
。Name = cstr(Left(strFiles, Application。
Find("。", strFiles) - 1))。收起