![]() |
#2
风吹过b2015-09-26 10:07
|
代码中With ActiveSheet.QueryTables.Add(Connection:= _
"TEXT;C:\Users\THINK\Desktop\数据.txt", Destination:=Range("Sheet1!$A$1"))要怎么改才可以?

Private Sub Macro(A() As String)
Dim n As Integer
n = Val(Text1.Text)
Dim i As Integer
For i = 1 To n
Debug.Print A(i)
Sheets("Sheet" & i).Select
With ActiveSheet.QueryTables.Add(Connection:= _
"TEXT;C:\Users\THINK\Desktop\数据.txt", Destination:=Range("$A$1"))
.Name = "1"
.FieldNames = True
.RowNumbers = False
.FillAdjacentFormulas = False
.PreserveFormatting = True
.RefreshOnFileOpen = False
.RefreshStyle = xlInsertDeleteCells
.SavePassword = False
.SaveData = True
.AdjustColumnWidth = True
.RefreshPeriod = 0
.TextFilePromptOnRefresh = False
.TextFilePlatform = 936
.TextFileStartRow = 1
.TextFileParseType = xlDelimited
.TextFileTextQualifier = xlTextQualifierDoubleQuote
.TextFileConsecutiveDelimiter = True
.TextFileTabDelimiter = True
.TextFileSemicolonDelimiter = False
.TextFileCommaDelimiter = False
.TextFileSpaceDelimiter = True
.TextFileColumnDataTypes = Array(1, 1, 1, 1)
.TextFileTrailingMinusNumbers = True
.Refresh BackgroundQuery:=False
End With
Next
End Sub
Dim n As Integer
n = Val(Text1.Text)
Dim i As Integer
For i = 1 To n
Debug.Print A(i)
Sheets("Sheet" & i).Select
With ActiveSheet.QueryTables.Add(Connection:= _
"TEXT;C:\Users\THINK\Desktop\数据.txt", Destination:=Range("$A$1"))
.Name = "1"
.FieldNames = True
.RowNumbers = False
.FillAdjacentFormulas = False
.PreserveFormatting = True
.RefreshOnFileOpen = False
.RefreshStyle = xlInsertDeleteCells
.SavePassword = False
.SaveData = True
.AdjustColumnWidth = True
.RefreshPeriod = 0
.TextFilePromptOnRefresh = False
.TextFilePlatform = 936
.TextFileStartRow = 1
.TextFileParseType = xlDelimited
.TextFileTextQualifier = xlTextQualifierDoubleQuote
.TextFileConsecutiveDelimiter = True
.TextFileTabDelimiter = True
.TextFileSemicolonDelimiter = False
.TextFileCommaDelimiter = False
.TextFileSpaceDelimiter = True
.TextFileColumnDataTypes = Array(1, 1, 1, 1)
.TextFileTrailingMinusNumbers = True
.Refresh BackgroundQuery:=False
End With
Next
End Sub