ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   getting error out of memory (https://www.excelbanter.com/excel-programming/350247-getting-error-out-memory.html)

Hilda

getting error out of memory
 
I'm Importing data from a text file to Excel, and everything is ok if I have
data in my text file, but I'm getting an out of memory error message at a
..Refresh BackgroundQuery:=False when my text file doesn't have data.

How can I test if my text file is empty or not?

Could somebody tell me why or what could I do about it???
this is my code...

Range("A2").Select
With ActiveSheet.QueryTables.Add(Connection:= _
"TEXT;C:\Hilda\Excel\WorryParts\WP1", Destination:=Range("A2"))
.Name = "WP1_1"
.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)
.TextFileTrailingMinusNumbers = True
.Refresh BackgroundQuery:=False
End With

Thanks a lot.

Tom Ogilvy

getting error out of memory
 
Test it with something like

if Dir("C:\Hilda\Excel\WorryParts\WP1") < "" Then
if filelen(C:\Hilda\Excel\WorryParts\WP1) 100 then
' now your code.

End if
End if

--
Regards,
Tom Ogilvy

"Hilda" wrote in message
...
I'm Importing data from a text file to Excel, and everything is ok if I

have
data in my text file, but I'm getting an out of memory error message at a
.Refresh BackgroundQuery:=False when my text file doesn't have data.

How can I test if my text file is empty or not?

Could somebody tell me why or what could I do about it???
this is my code...

Range("A2").Select
With ActiveSheet.QueryTables.Add(Connection:= _
"TEXT;C:\Hilda\Excel\WorryParts\WP1", Destination:=Range("A2"))
.Name = "WP1_1"
.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)
.TextFileTrailingMinusNumbers = True
.Refresh BackgroundQuery:=False
End With

Thanks a lot.





All times are GMT +1. The time now is 02:07 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com