+ Reply to Thread
Results 1 to 9 of 9

help with "invalid procedure call or argument" error.

  1. #1
    Forum Contributor
    Join Date
    01-09-2016
    Location
    USA,USA
    MS-Off Ver
    2016
    Posts
    1,192

    help with "invalid procedure call or argument" error.

    I cannot figure out what is wrong with this code. I've run it on one workbook and it worked like it always does. Then I run it on the one I need and it fails after seven exports. I even moved the eight sheet to the front to see if that was causing it to fail. Nope. It has something to do with the filenames of about 13 of them. I can't provide those, they are personal info, but I am hoping someone might point me in the right direction for why I am getting "invalid procedure call or argument" error (see bolded part in code below). I can't do an On Error Resume Next, because it puts Exported next to the file that would have otherwise stopped to exports. It needs to say the Not exported, then I can troubleshoot.

    Please Login or Register  to view this content.
    Attached Images Attached Images
    Attached Files Attached Files
    Last edited by taylorsm; 05-02-2017 at 11:33 AM.

  2. #2
    Forum Expert
    Join Date
    02-14-2009
    Location
    .
    MS-Off Ver
    ................
    Posts
    2,840

    Re: help with "invalid procedure call or argument" error.

    I can't do an On Error Resume Next...
    But you can add some 'real' error handling, such as it exists in VBA, so you can query the value of the various variables which may help you to figure out what's happening.

    Also, just saying "I am getting 'invalid procedure call or argument' error" without saying which line errors limits the responses you're going to get...

  3. #3
    Forum Contributor
    Join Date
    01-09-2016
    Location
    USA,USA
    MS-Off Ver
    2016
    Posts
    1,192

    Re: help with "invalid procedure call or argument" error.

    But I do have the error sectioned bolded in the code, I failed to point that out though. I'll update

    I know nothing about 'real' error handling. Error Resume Next is the extent that I know.

  4. #4
    Forum Expert
    Join Date
    02-14-2009
    Location
    .
    MS-Off Ver
    ................
    Posts
    2,840

    Re: help with "invalid procedure call or argument" error.

    The bold text hardly stands out - it would have been much simpler to simply say which line.

    I know nothing about 'real' error handling
    I would strongly suggest you learn, or at least have a read of the link in my first reply. it's simple and has one major advantage - you can handle errors gracefully, and possibly correct them.

    On Error Resume Next does not correct errors, it simply ignores them. All that happens is the errors can get compounded and the user is none the wiser. What if you were totalling the years Revenue Vs Costs? Revenue sums fine, the Costs calculation errors a few times. How popular would you be when the boss finds out the profit is not exactly what you calculated it to be?

    Out of context, and not knowing anything about the values you are working with, I have no idea what the error is. I could guess but it would only be a guess.

  5. #5
    Forum Guru Norie's Avatar
    Join Date
    02-02-2005
    Location
    Stirling, Scotland
    MS-Off Ver
    Microsoft Office 365
    Posts
    19,643

    Re: help with "invalid procedure call or argument" error.

    Is this where you get the error?
    Please Login or Register  to view this content.
    If so check that fPATH is valid path to a folder and fNAME is a valid filename.

    Also, check you have permissing to right to the folder fPATH points to.
    If posting code please use code tags, see here.

  6. #6
    Forum Contributor
    Join Date
    01-09-2016
    Location
    USA,USA
    MS-Off Ver
    2016
    Posts
    1,192

    Re: help with "invalid procedure call or argument" error.

    I understand it doesn't stand out, that is why I said I should have pointed it out. And, I can read the link, but that doesn't really assist with my immediate need. I know I would be none the wiser, hence why I stated that I can't use Resume Next because it marks them as exported when they are not. If the error would flag the cell somehow and then continue on, then I could circle back around and fix (if I can figure out why it failed), As this code is for exporting as a PDF, then there is no totalling to be done wrong. Simply one file would not be exported with the others. Ideally exporting 250 sheets would not stop because ten rows in, one file name was wrong.

    And as i mentioned, i can't provide a sample because it is personal and modifying it would likely modify the problem, I was looking more for a dumb down version of what that error meant so I could try and figure out the issue.

  7. #7
    Forum Contributor
    Join Date
    01-09-2016
    Location
    USA,USA
    MS-Off Ver
    2016
    Posts
    1,192

    Re: help with "invalid procedure call or argument" error.

    Norie, thanks. Yes that is where. And this is exporting 250 spreadsheets. It works on 238 of them. It is 12 sheets that do not work and they the exact same format and everything. I am trying to make a sample, but it is proving difficult

  8. #8
    Forum Contributor
    Join Date
    01-09-2016
    Location
    USA,USA
    MS-Off Ver
    2016
    Posts
    1,192

    Re: help with "invalid procedure call or argument" error.

    Norie, I attached a workbook to my first post.

  9. #9
    Forum Contributor
    Join Date
    01-09-2016
    Location
    USA,USA
    MS-Off Ver
    2016
    Posts
    1,192

    Re: help with "invalid procedure call or argument" error.

    So it has something to do with the folder name length. If I rename the same folder to something short it works. If I try a new folder with a long name, it doesn't.

    Is there a way to avoid this in the future other than just remembering


    Edit*

    That can't be why though, I did this same thing in February and it worked fine. i even did it today again to check my code. Exact same filename except instead of April it had February.....
    Last edited by taylorsm; 05-02-2017 at 12:13 PM.

+ 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] Invalid procedure call or argument error
    By maym in forum Excel Programming / VBA / Macros
    Replies: 10
    Last Post: 07-10-2016, 09:38 PM
  2. [SOLVED] run time error '5" invalid procedure call or argument
    By jay11 in forum Excel Programming / VBA / Macros
    Replies: 8
    Last Post: 05-12-2015, 12:29 PM
  3. Run-time Error 5 "Invalid Procedure Call or Argument"
    By dinakar.yadav in forum Excel Programming / VBA / Macros
    Replies: 6
    Last Post: 04-15-2014, 09:22 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. WritetoSheet causing "invalid procedure call or argument"
    By cmb80 in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 09-11-2013, 03:46 PM
  6. "Invalid procedure call or argument" error when creating Pivot table
    By Kaigi in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 10-31-2009, 06:02 AM
  7. [SOLVED] 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

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