+ Reply to Thread
Results 1 to 12 of 12

Run Time Error 52

  1. #1
    Forum Contributor
    Join Date
    09-05-2012
    Location
    Dubai
    MS-Off Ver
    Office 365
    Posts
    409

    Run Time Error 52

    Hi, Kindly assist here to solve my issue.
    I am getting error as Run time error 52 Bad file name or Number

    and showing bug at highlighted line

    I also seen the file name in Immediate window, pls check in below picture.

    Kindly advise what can be the VBA code to handle this error.
    Attached Images Attached Images

  2. #2
    Forum Expert Keebellah's Avatar
    Join Date
    01-12-2014
    Location
    The Netherlands
    MS-Off Ver
    Office 2021 (Windows)
    Posts
    7,937

    Re: Run Time Error 52

    The code should be

    Please Login or Register  to view this content.
    Code is typed not tested but this is the syntax for Dir and checking if the file is found
    Last edited by Keebellah; 04-23-2018 at 03:13 PM. Reason: Type ooo
    ---
    Hans
    "IT" Always crosses your path!
    May the (vba) code be with you... if it isn't; start debugging!
    If you like my answer, Click the * below to say thank-you

  3. #3
    Forum Contributor
    Join Date
    09-05-2012
    Location
    Dubai
    MS-Off Ver
    Office 365
    Posts
    409

    Re: Run Time Error 52

    Hi Keebellah, It is the same error again appeared at highlighted line even after modified as per your code.
    Attached Images Attached Images

  4. #4
    Forum Guru
    Join Date
    07-25-2011
    Location
    Florida
    MS-Off Ver
    Excel 2003
    Posts
    9,653

    Re: Run Time Error 52

    If you do not have a drive D, you get that error.

    Try something like this...

    Please Login or Register  to view this content.
    Last edited by AlphaFrog; 04-23-2018 at 03:32 PM. Reason: missed the Else command
    Surround your VBA code with CODE tags e.g.;
    [CODE]your VBA code here[/CODE]
    The # button in the forum editor will apply CODE tags around your selected text.

  5. #5
    Forum Expert Keebellah's Avatar
    Join Date
    01-12-2014
    Location
    The Netherlands
    MS-Off Ver
    Office 2021 (Windows)
    Posts
    7,937

    Re: Run Time Error 52

    The you have either not assigned a value to WSAdmn
    If I type
    Please Login or Register  to view this content.
    it works here so the problem lies in the variables you're using.

  6. #6
    Forum Contributor
    Join Date
    09-05-2012
    Location
    Dubai
    MS-Off Ver
    Office 365
    Posts
    409

    Re: Run Time Error 52

    @Alpha, Yes your guess is absolutely right, in my PC D: refers to CD drive...
    I applied your code but same error again appeared
    Attached Images Attached Images

  7. #7
    Forum Guru
    Join Date
    07-25-2011
    Location
    Florida
    MS-Off Ver
    Excel 2003
    Posts
    9,653

    Re: Run Time Error 52

    Quote Originally Posted by naveenmarapaka View Post
    @Alpha, Yes your guess is absolutely right, in my PC D: refers to CD drive...
    I applied your code but same error again appeared
    Try using the FileSystemObject instead of Dir.
    Declare and set fso before your loop.

    Please Login or Register  to view this content.

  8. #8
    Forum Expert Keebellah's Avatar
    Join Date
    01-12-2014
    Location
    The Netherlands
    MS-Off Ver
    Office 2021 (Windows)
    Posts
    7,937

    Re: Run Time Error 52

    What is the value op the cell you're readin?

    WSAdmn.Range("P" & admnRow).value

  9. #9
    Forum Contributor
    Join Date
    09-05-2012
    Location
    Dubai
    MS-Off Ver
    Office 365
    Posts
    409

    Re: Run Time Error 52

    I would not close my thread as solved without saying Thank you to you Alpha.

    It really worked like a wonder finally.

    thanks a million.

  10. #10
    Forum Guru
    Join Date
    07-25-2011
    Location
    Florida
    MS-Off Ver
    Excel 2003
    Posts
    9,653

    Re: Run Time Error 52

    Quote Originally Posted by naveenmarapaka View Post
    I would not close my thread as solved without saying Thank you to you Alpha.

    It really worked like a wonder finally.

    thanks a million.
    You're welcome. Thanks for the feedback.

    You should thank Keebellah as well.

  11. #11
    Forum Contributor
    Join Date
    09-05-2012
    Location
    Dubai
    MS-Off Ver
    Office 365
    Posts
    409

    Re: Run Time Error 52

    Yes Ofcourse thank you Keebellah for your great Support as well

  12. #12
    Forum Expert Keebellah's Avatar
    Join Date
    01-12-2014
    Location
    The Netherlands
    MS-Off Ver
    Office 2021 (Windows)
    Posts
    7,937

    Re: Run Time Error 52

    You're welcome, nice to hear we all added our grain of sand to help

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Similar Threads

  1. [SOLVED] Error message: Run-Time error '1004 '; application-defined or object-defined error
    By Davasu in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 10-23-2015, 06:52 AM
  2. Replies: 1
    Last Post: 10-22-2015, 05:50 AM
  3. VBA ERROR: run time error 1004: Application-defined or Object-defined error in excel 2013
    By AnanthKrishna in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 02-13-2015, 06:16 AM
  4. Cannot Publish Excel Pivot Chart - Run Time Error
    By crisb184 in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 10-11-2013, 07:04 AM
  5. [SOLVED] Error " Run-time error '1004': application defined or object defined error
    By lengwer in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 09-11-2013, 07:26 AM
  6. run-time error ;2147023179 (800706b5) time automation error interface unknown
    By karthik72 in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 11-02-2012, 09:31 AM
  7. Error "run-time Error '1004': General Odbc Error
    By D4WNO77 in forum Access Tables & Databases
    Replies: 2
    Last Post: 07-16-2012, 09:55 AM

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