+ Reply to Thread
Results 1 to 3 of 3

runtime error 52 bad file name or number

  1. #1
    Registered User
    Join Date
    01-16-2013
    Location
    US
    MS-Off Ver
    Excel 2007
    Posts
    3

    runtime error 52 bad file name or number

    I am using Excel 2007, I have the code below it tries to run and when it gets 513 files it gives me the error message "runtime error 52 bad file name or number"
    What i have is I select txt files then open each one put those into an array. Then i have some other code that goes to each array(file) and checks for some information that i am interested in.

    When i went to debug it took me to Open mFleNm For Input As #file, I put the mouse over the mFleNm and the path looks correct and the file was 513. I had selectd 945 files.

    Please Login or Register  to view this content.
    Any ideas what is causing this to stop and give the error mentioned above.

    Your help is appreciated.

    Thanks


    Moderator's Note: Welcome to the forum. Codes should be enclosed with code tags. Select the code then hit the "#" sign. I'll do it for you now. Thanks.
    Last edited by vlady; 01-17-2013 at 01:18 AM.

  2. #2
    Forum Expert
    Join Date
    11-29-2010
    Location
    Ukraine
    MS-Off Ver
    Excel 2019
    Posts
    4,168

    Re: runtime error 52 bad file name or number

    hi fabdullaster, welcome to Excelforum, the problem comes from file variable being simultaneously used as FreeFile and loop counter. Make them separate variables(differently named) and it should be ok then

  3. #3
    Forum Expert
    Join Date
    11-29-2010
    Location
    Ukraine
    MS-Off Ver
    Excel 2019
    Posts
    4,168

    Re: runtime error 52 bad file name or number

    or alternatively do not use a separate variable for FreeFil:

    Please Login or Register  to view this content.

+ 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