Hello,

I record a macro for importing text file into excel.
After some imports I found that many connections were added to excel workbook.
How can I close the connection after copying the text to my workbook ?

Thank you for your help


With TargetWorkbook.Sheets(Temp).QueryTables.Add(Connection:="TEXT;" & strFileFullPath, Destination:=TargetWorkbook.Sheets(Temp).Range("$A$1"))
             .Name = strFileName
             .FieldNames = True
             .RowNumbers = False
             .FillAdjacentFormulas = False
             .PreserveFormatting = True
             .RefreshOnFileOpen = False
             .RefreshStyle = xlInsertDeleteCells
             .SavePassword = False
             .SaveData = True
             .AdjustColumnWidth = True
             .RefreshPeriod = 0
             .TextFilePromptOnRefresh = False
             .TextFilePlatform = 862
             .TextFileStartRow = 1
             .TextFileParseType = xlDelimited
             .TextFileTextQualifier = xlTextQualifierDoubleQuote
             .TextFileConsecutiveDelimiter = False
             .TextFileTabDelimiter = True
             .TextFileColumnDataTypes = Array(1, 1, 1, 1, 1, 1, 1, 1, 1, 1)
             .TextFileTrailingMinusNumbers = True
             .Refresh BackgroundQuery:=False
   End With