+ Reply to Thread
Results 1 to 6 of 6

Macro fails to import text files

  1. #1
    Forum Contributor Rick_Stanich's Avatar
    Join Date
    11-21-2005
    Location
    Ladson SC
    MS-Off Ver
    Office365
    Posts
    1,167

    Macro fails to import text files

    The only reason I can think of is moving from Excel 2003 to 2007.

    My macro imports text files based on certain criteria in a folder "_chr.txt", the macro runs through, show in a message box that x files were imported but nothing is there. I get a small, strange character in cell A1 (Upper left corner) and the entire row (A) is highlighted.

    I cant figure out what needs to be modified, except maybe in my Function (ImportFile)?

    Please Login or Register  to view this content.
    Attached is a sample text file.
    Imported as "comma delimited" (The only delimiter is "Tab"), inserted into Cell A1.

    Any help, hints or tips are appreciated.
    Regards

    Rick
    Win10, Office 365

  2. #2
    Forum Contributor Rick_Stanich's Avatar
    Join Date
    11-21-2005
    Location
    Ladson SC
    MS-Off Ver
    Office365
    Posts
    1,167

    Re: Macro fails to import text files

    Added image to show cell A1 after running macros
    Attached Images Attached Images

  3. #3
    Forum Expert mike7952's Avatar
    Join Date
    12-17-2011
    Location
    Florida
    MS-Off Ver
    Excel 2007, Excel 2016
    Posts
    3,520

    Re: Macro fails to import text files

    Heres a little different approach

    Please Login or Register  to view this content.
    Thanks,
    Mike

    If you are satisfied with the solution(s) provided, please mark your thread as Solved.
    Select Thread Tools-> Mark thread as Solved.

  4. #4
    Forum Contributor Rick_Stanich's Avatar
    Join Date
    11-21-2005
    Location
    Ladson SC
    MS-Off Ver
    Office365
    Posts
    1,167

    Re: Macro fails to import text files

    I hate you people and your simple solutions!

    Thank you.

  5. #5
    Forum Contributor Rick_Stanich's Avatar
    Join Date
    11-21-2005
    Location
    Ladson SC
    MS-Off Ver
    Office365
    Posts
    1,167

    Re: Macro fails to import text files

    Quote Originally Posted by mike7952 View Post
    Heres a little different approach

    Please Login or Register  to view this content.
    I'm bringing up this older post because I am trying to utilize the code in Office365.
    It fails at:
    Please Login or Register  to view this content.
    With "Run-time error '9': Subscript out of range

    I want to read a text file:
    3031879-001_-_Block Shaft Assy-Addendum_10-03-2023_Serial No._1_2023-10-05_9_30_59 AM_chr.txt
    (Attached) and place the data on Sheet4.
    (I will eventually be reading in many text files at once).

    Any assistance is appreciated.
    Last edited by Rick_Stanich; 10-16-2023 at 11:06 AM.

  6. #6
    Forum Expert
    Join Date
    08-17-2007
    Location
    Poland
    Posts
    2,248

    Re: Macro fails to import text files

    Verify that the full path to the FOLDER ends with a path separator.

    Artik

+ 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