首页 > 代码库 > VBA 以文本格式打开DSV
VBA 以文本格式打开DSV
Public Function GetDataFromDSV(fpath As String) As Collection Dim AllTextFormat(255) As Integer Dim i As Long For i = 0 To 255 AllTextFormat(i) = xlTextFormat Next i Application.ScreenUpdating = False Application.DisplayAlerts = False Application.Workbooks.Add With ActiveWorkbook.Sheets(1).QueryTables.Add(Connection:= _ "TEXT;" & fpath, Destination:=Range("$A$1")) ‘.Name = "test_1" .PreserveFormatting = True ‘.TextFilePlatform = 936 简体中文 932 JIS 65001 UTF-8 .TextFileCommaDelimiter = True .TextFileColumnDataTypes = AllTextFormat .Refresh BackgroundQuery:=False End With With ActiveWorkbook.Sheets(1) ‘执行逻辑代码 End With ActiveWorkbook.Close False Application.ScreenUpdating = True Application.DisplayAlerts = True End Function
声明:以上内容来自用户投稿及互联网公开渠道收集整理发布,本网站不拥有所有权,未作人工编辑处理,也不承担相关法律责任,若内容有误或涉及侵权可进行投诉: 投诉/举报 工作人员会在5个工作日内联系你,一经查实,本站将立刻删除涉嫌侵权内容。