+ Reply to Thread
Results 1 to 6 of 6

import file problem

  1. #1
    Registered User
    Join Date
    01-06-2006
    Posts
    8

    import file problem

    Hi,

    I have a problem importing a file into Excel. Problem is that Excel doesn't recognize the new line character used in the file. The following code puts all data into one line, while I need to have them seperated. Working with the ResultStr results in an 'out of memory' exception. (I actually only need one particular line from my file.)

    Please Login or Register  to view this content.

    The automatic way does work, but this will chop off the wanted line to 256 chars. (line 8, the one with all the '--')
    Please Login or Register  to view this content.
    Anyone knows the best way to fetch that line of code from the file?

    thanks in advance,

    Sven

    *update*
    apparently, the automatic way doesn't chop off other strings longer then 256 chars. It only does that with the '--'-line?
    Attached Files Attached Files
    Last edited by naaitie; 10-30-2007 at 09:24 AM.

  2. #2
    Forum Expert
    Join Date
    01-15-2007
    Location
    Brisbane, Australia
    MS-Off Ver
    2007
    Posts
    6,591
    Sven

    The file doesn't have a CR, or a CR LF required for the line input.

    I opened the text file in Word, then resaved as a new file using the windows default to make it readable. I then saved the file as a new text file (LIJST2.TXT) using the windows default and the CR/LF selection in the ends lines with.

    The following seemed to parse the file correctly and output to the current sheet.

    Please Login or Register  to view this content.
    HTH

    rylo

  3. #3
    Registered User
    Join Date
    01-06-2006
    Posts
    8
    I have indeed noticed that it worked when saving the file through Wordpad first. However, as the input-file is generated automatically from an other program, it is not possible to change anything concerning this file.

    I have tried your code on the original file, but that didn't work either.


    thanks for the input,

    Sven

  4. #4
    Valued Forum Contributor mudraker's Avatar
    Join Date
    11-10-2003
    Location
    Melbourne, Australia
    Posts
    3,983
    Have you tried importing the file without splitting ito columns 1st

    Please Login or Register  to view this content.
    This give row 8 with 352 characters
    Please Read Forum Rules Before Posting
    Wrap VBA code by selecting the code and clicking the # icon or Read This
    How To Cross Post politely

    Top Excel links for beginners to Experts

    If you are pleased with a member's answer then use the Scales icon to rate it
    If my reply has assisted or failed to assist you I welcome your Feedback.

  5. #5
    Registered User
    Join Date
    01-06-2006
    Posts
    8
    thanks! This thing does the trick.

    I had already tried without splitting it into columns & it didn't help, but your code did!

    One performance-remark: is it possible to add something like an 'TextFileEndRow = x' to that code? Then I could specify that it should only fetch that one line.
    I have google'ed on this but it came up empty.

  6. #6
    Valued Forum Contributor mudraker's Avatar
    Join Date
    11-10-2003
    Location
    Melbourne, Australia
    Posts
    3,983
    Not that I am aware of

    Glad to hear the code works

+ 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