+ Reply to Thread
Results 1 to 11 of 11

Invalid procedure call or argument error

  1. #1
    Forum Contributor
    Join Date
    10-12-2011
    Location
    Sydney
    MS-Off Ver
    Excel 2016 in 2024
    Posts
    857

    Invalid procedure call or argument error

    Hi

    I have the following code to open each file in a directory and then call on two other macros. It works for a little but then stops and I receive the "Invalid procedure call or argument" error at the line "Filename = Dir". Is there something I have wrong?
    Please Login or Register  to view this content.

  2. #2
    Forum Expert Kenneth Hobson's Avatar
    Join Date
    02-05-2007
    Location
    Tecumseh, OK
    MS-Off Ver
    Office 365, Win10Home
    Posts
    2,573

    Re: Invalid procedure call or argument error

    Do you have a Dir in one of the other routines?

  3. #3
    Forum Contributor
    Join Date
    10-12-2011
    Location
    Sydney
    MS-Off Ver
    Excel 2016 in 2024
    Posts
    857

    Re: Invalid procedure call or argument error

    Yes, it is in the "Test_File_Exists_With_Dir_v1" macro, as shown below"

    Please Login or Register  to view this content.

  4. #4
    Forum Contributor
    Join Date
    10-12-2011
    Location
    Sydney
    MS-Off Ver
    Excel 2016 in 2024
    Posts
    857

    Re: Invalid procedure call or argument error

    any way this can be solved Kenneth?

  5. #5
    Forum Expert Kenneth Hobson's Avatar
    Join Date
    02-05-2007
    Location
    Tecumseh, OK
    MS-Off Ver
    Office 365, Win10Home
    Posts
    2,573

    Re: Invalid procedure call or argument error

    I know of 4 ways. Some make an array of filenames. You can then iterate the array. If you have just the root folder to iterate, I can show you the Dir() method to create an array. Here is one such method.
    Please Login or Register  to view this content.

    My batch method gives you all the power and options of the command shell's DIR method which is nothing like VBA's Dir() method.
    HTML Code: 

  6. #6
    Forum Contributor
    Join Date
    10-12-2011
    Location
    Sydney
    MS-Off Ver
    Excel 2016 in 2024
    Posts
    857

    Re: Invalid procedure call or argument error

    thank you Kenneth.

    Where would I place the code above in relation to both of my macros?

  7. #7
    Forum Contributor
    Join Date
    10-12-2011
    Location
    Sydney
    MS-Off Ver
    Excel 2016 in 2024
    Posts
    857

    Re: Invalid procedure call or argument error

    this obviously gives me the names of the files but how can I use this in relation to my original problem Kenneth?

  8. #8
    Forum Expert Kenneth Hobson's Avatar
    Join Date
    02-05-2007
    Location
    Tecumseh, OK
    MS-Off Ver
    Office 365, Win10Home
    Posts
    2,573

    Re: Invalid procedure call or argument error

    The test routines show how. Once you have the array, just iterate it in a For i = lbound(arrayname) to ubound(arrayname) or a For Each variantvariable in arrayname loop.

  9. #9
    Forum Contributor
    Join Date
    10-12-2011
    Location
    Sydney
    MS-Off Ver
    Excel 2016 in 2024
    Posts
    857

    Re: Invalid procedure call or argument error

    thanks Kenneth. Unfortunately I do not know how to do this. If you could assist me further, that would be really appreciated.

  10. #10
    Forum Expert Kenneth Hobson's Avatar
    Join Date
    02-05-2007
    Location
    Tecumseh, OK
    MS-Off Ver
    Office 365, Win10Home
    Posts
    2,573

    Re: Invalid procedure call or argument error

    Please Login or Register  to view this content.

  11. #11
    Forum Contributor
    Join Date
    10-12-2011
    Location
    Sydney
    MS-Off Ver
    Excel 2016 in 2024
    Posts
    857

    Re: Invalid procedure call or argument error

    thanks Kenneth, worked perfectly.

+ 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. Run-time error '5' - Invalid procedure call or argument
    By datutt in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 10-14-2015, 12:12 PM
  2. Run Time Error 5 Invalid Procedure Call or Argument
    By esong_98 in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 06-28-2015, 03:31 PM
  3. Run-time error '5' Invalid procedure call or argument
    By CCSlice in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 04-07-2015, 03:21 AM
  4. Invalid procedure call or argument (Error 5)
    By vop2311 in forum Excel Programming / VBA / Macros
    Replies: 5
    Last Post: 04-08-2014, 07:27 PM
  5. Runtime Error 5: Invalid procedure call or argument
    By Arasi in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 10-07-2009, 11:49 AM
  6. Invalid procedure call or argument error
    By Patrick Simonds in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 08-12-2006, 06:45 PM
  7. Run Time Error 5 - Invalid Procedure Call or Argument Q
    By John in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 09-26-2005, 05:05 PM

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