+ Reply to Thread
Results 1 to 5 of 5

Excel 2010 vba problem

  1. #1
    Registered User
    Join Date
    06-05-2011
    Location
    london, england
    MS-Off Ver
    Excel 2010
    Posts
    2

    Excel 2010 vba problem

    I've written a routine that loops through .txt files in a directory and reads one line at a time from the files into a row in excel. This code was functional and working, but now for no clear reason it gives me the error message, Run time error '53', File Not Found when trying to open any of the txt files.

    The code has not changed, the path and files have not changed. Doesn't seem to matter what I do, whatever file I try to open I always get that message.

    Could something have changed in the operating system? (I'm running Win7pro.) Any help appreciated.

  2. #2
    Forum Guru TMS's Avatar
    Join Date
    07-15-2010
    Location
    The Great City of Manchester, NW England ;-)
    MS-Off Ver
    MSO 2007,2010,365
    Posts
    44,090

    Re: Excel 2010 vba problem

    What would you have us investigate? No workbook, no code, no text files ...

    Regards
    Trevor Shuttleworth - Retired Excel/VBA Consultant

    I dream of a better world where chickens can cross the road without having their motives questioned

    'Being unapologetic means never having to say you're sorry' John Cooper Clarke


  3. #3
    Forum Expert snb's Avatar
    Join Date
    05-09-2010
    Location
    VBA
    MS-Off Ver
    Redhat
    Posts
    5,649

    Re: Excel 2010 vba problem

    You probably used application.filesearch that doesn't exist anymore in Excel 2007 and Excel 2010.
    Use Dir instead.



  4. #4
    Registered User
    Join Date
    06-05-2011
    Location
    london, england
    MS-Off Ver
    Excel 2010
    Posts
    2

    Re: Excel 2010 vba problem

    Here is the code:

    strPath = "C:\Projects\2010Data\Import\*.txt"
    strFile = Dir(strPath)
    intRow = 1
    Do While strFile <> ""
    Open strFile For Input As #1 (*** Error occurs here ***)
    Do While Not EOF(1)
    Line Input #1, strInput
    Worksheets(1).Cells(intRow, 1).Value = strInput
    Worksheets(1).Cells(intRow, 1).TextToColumns DataType:=xlDelimited, ConsecutiveDelimiter:=False, Comma:=True
    intRow = intRow + 1
    Loop
    Close #1
    strFile = Dir
    Loop

  5. #5
    Forum Expert royUK's Avatar
    Join Date
    11-18-2003
    Location
    Derbyshire,UK
    MS-Off Ver
    Xp; 2007; 2010
    Posts
    26,200

    Re: Excel 2010 vba problem

    Your post does not comply with Rule 1 of our Forum RULES. Your post title should accurately and concisely describe your problem, not your anticipated solution. Use terms appropriate to a Google search. Poor thread titles, like Please Help, Urgent, Need Help, Formula Problem, Code Problem, and Need Advice will be addressed according to the OP's experience in the forum: If you have less than 10 posts, expect (and respond to) a request to change your thread title. If you have 10 or more posts, expect your post to be locked, so you can start a new thread with an appropriate title.
    To change a Title on your post, click EDIT then Go Advanced and change your title, if 2 days have passed ask a moderator to do it for you.

    PLEASE PM WHEN YOU HAVE DONE THIS AND I WILL DELETE THIS POST

    Your post does not comply with Rule 3 of our Forum RULES. Use code tags around code. Posting code without them makes your code hard to read and difficult to be copied for testing. Highlight your code and click the # at the top of your post window. For more information about these and other tags, found here
    Hope that helps.

    RoyUK
    --------
    For Excel Tips & Solutions, free examples and tutorials why not check out my web site

    Free DataBaseForm example

+ 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