"Out of memory error" on TextFileColumnDataTypes RRS feed

  • Question

  • I have a working macro that load a CSV file.

    Set conData = Application.ActiveWorkbook.Connections("...").TextConnection
    conData.Connection = ...

    If I try to enforce a column format, with the next line, it stops (on this line) with the message "Out of memory error".

    conData.TextFileColumnDataTypes = Array(xlTextFormat)

    Any idea? It still did not begin to read the file. I even tried to put this line right after the "Set conData = ..." line

    Thanks for any help
    Wednesday, July 12, 2017 2:42 PM

All replies

  • PS: I'm in Office365
    Wednesday, July 12, 2017 2:44 PM
  • Hello,

    Could you please share your whole code you are using now? 

    You use the following code to test your file. QueryTable.TextFileColumnDataTypes Property (Excel)

    Sub test()
    Set shFirstQtr = Workbooks(1).Worksheets(1)
    Set qtQtrResults = shFirstQtr.QueryTables _
     .Add(Connection:="TEXT;D:\1.csv", _
     Destination:=shFirstQtr.Cells(1, 1))
    With qtQtrResults
     .TextFileParseType = xlFixedWidth
    ' .TextFileFixedColumnWidths = Array(5, 4)
     .TextFileColumnDataTypes = _
    End With
    End Sub



    MSDN Community Support
    Please remember to click "Mark as Answer" the responses that resolved your issue, and to click "Unmark as Answer" if not. This can be beneficial to other community members reading this thread. If you have any compliments or complaints to MSDN Support, feel free to contact

    Tuesday, July 18, 2017 5:46 AM