Sub ImportTXT ()
'
With ActiveSheet. QueryTables. Add (Connection:=_
"TEXT. E: \ data \ pmtest \ Sample of TXT pose TXT ", Destination:=Range (" $A $4"))
'CommandType=0
.name="Sample of TXT pose"
The FieldNames=True
. RowNumbers=False
. FillAdjacentFormulas=False
. PreserveFormatting=True
. RefreshOnFileOpen=False
. RefreshStyle=xlInsertDeleteCells
. SavePassword=False
. A SaveData=https://bbs.csdn.net/topics/True
. AdjustColumnWidth=True
. RefreshPeriod=0
. TextFilePromptOnRefresh=False
TextFilePlatform=862
. TextFileStartRow=1
. TextFileParseType=xlDelimited
. TextFileTextQualifier=xlTextQualifierDoubleQuote
. TextFileConsecutiveDelimiter=True
. TextFileTabDelimiter=False
. TextFileSemicolonDelimiter=False
. TextFileCommaDelimiter=False
. TextFileSpaceDelimiter=True
TextFileColumnDataTypes=Array (1, 1, 1, 1, 1, 1, 1)
. TextFileTrailingMinusNumbers=True
The Refresh BackgroundQuery:=False
End With
End Sub
Want to change to relative path, the following is the code
Sub ImportTXT ()
'
With ActiveSheet. QueryTables. Add (Connection:=_
"TEXT. "& amp; ThisWorkbook. Path & amp; "\ Sample of TXT pose. TXT" "" , Destination:=Range (" $A $4"))
'CommandType=0
.name="Sample of TXT pose"
The FieldNames=True
. RowNumbers=False
. FillAdjacentFormulas=False
. PreserveFormatting=True
. RefreshOnFileOpen=False
. RefreshStyle=xlInsertDeleteCells
. SavePassword=False
. A SaveData=https://bbs.csdn.net/topics/True
. AdjustColumnWidth=True
. RefreshPeriod=0
. TextFilePromptOnRefresh=False
TextFilePlatform=862
. TextFileStartRow=1
. TextFileParseType=xlDelimited
. TextFileTextQualifier=xlTextQualifierDoubleQuote
. TextFileConsecutiveDelimiter=True
. TextFileTabDelimiter=False
. TextFileSemicolonDelimiter=False
. TextFileCommaDelimiter=False
. TextFileSpaceDelimiter=True
TextFileColumnDataTypes=Array (1, 1, 1, 1, 1, 1, 1)
. TextFileTrailingMinusNumbers=True
The Refresh BackgroundQuery:=False
End With
End Sub
But will run report cannot access the file '1004' kind of wrong, great god, please give directions to see what is going wrong don't appreciate,
CodePudding user response:
VB no earlierCodePudding user response:
I also want to know theCodePudding user response:
"TEXT." & ThisWorkbook. Path & amp; "\ Sample of TXT pose. TXT" ""-
The last two quotes a bit redundant, remove to
"TEXT." & ThisWorkbook. Path & amp; "\ Sample of TXT pose. TXT"
Save, open the EXCEL run again to see,
CodePudding user response:
Antique stick...CodePudding user response:
Quotes not matching, changed the line