VBA for Importing Text Files
Martin,
Check the help for the MultiSelect argument to GetOpenFilename .
Note that you get an array returned, that you can then loop through.
NickHK
"Martin" wrote in message
...
My Current VBA for import test files are as follow, how can I select
mutiple
files at one time instead of clicking one by one? Ctrl and Shift button
does
not work in this. Thanks.
Sub Import()
Dim myFileName As Variant
Do
myFileName = Application.GetOpenFilename( _
filefilter:="Text Files, *.Txt", Title:="Locate &
Select
the Reel No.")
If myFileName = False Then
MsgBox "End of Import. Copy Worksheet to Smartscope
Summary.xls"
'user hit cancel
Else
With ActiveSheet.QueryTables.Add( _
Connection:="TEXT;" & myFileName, _
Destination:=Range("A1"))
.Name = "smartscope"
.FieldNames = True
.RowNumbers = False
.FillAdjacentFormulas = False
.PreserveFormatting = True
.RefreshOnFileOpen = False
.RefreshStyle = xlInsertDeleteCells
.SavePassword = False
.SaveData = True
.AdjustColumnWidth = True
.RefreshPeriod = 0
.TextFilePromptOnRefresh = False
.TextFilePlatform = 437
.TextFileStartRow = 1
.TextFileParseType = xlDelimited
.TextFileTextQualifier = xlTextQualifierDoubleQuote
.TextFileConsecutiveDelimiter = False
.TextFileTabDelimiter = True
.TextFileSemicolonDelimiter = False
.TextFileCommaDelimiter = False
.TextFileSpaceDelimiter = False
.TextFileColumnDataTypes = Array(1, 1, 1, 1, 1, 1, 1)
.TextFileTrailingMinusNumbers = True
.Refresh BackgroundQuery:=False
End With
End If
Loop Until myFileName = False
End Sub
|