+ Reply to Thread
Results 1 to 2 of 2

getting error out of memory

  1. #1
    Hilda
    Guest

    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.

  2. #2
    Tom Ogilvy
    Guest

    Re: 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" <[email protected]> wrote in message
    news:[email protected]...
    > 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.




+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1