I'm a bit stuck on this one.
I've imported data from a text file into Excel using the below code.
where sFullName is the full path and name of the file.
When I go to save the data back to sFullName,
I get an error message indicating the file is still open.
How can I close the file after importing the data?
Here's the code:
Thanks,
John
In Annapolis, MD
I've imported data from a text file into Excel using the below code.
where sFullName is the full path and name of the file.
When I go to save the data back to sFullName,
I get an error message indicating the file is still open.
How can I close the file after importing the data?
Here's the code:
Code:
'-- Import the Text File ----------------------------------------------
With ActiveSheet.QueryTables.Add(Connection:="TEXT;" & _
sFullName, _
Destination:=wsData.Range("$A$1"))
.Name = sName
.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 = xlTextQualifierNone
.TextFileConsecutiveDelimiter = True
.TextFileTabDelimiter = True
.TextFileSemicolonDelimiter = False
.TextFileCommaDelimiter = False
.TextFileSpaceDelimiter = False
.TextFileColumnDataTypes = Array(2)
.TextFileTrailingMinusNumbers = True
.Refresh BackgroundQuery:=False
End With
John
In Annapolis, MD