+ Reply to Thread
Results 1 to 18 of 18

Runtime Error 5 Invalid Procedure Call or Argument

  1. #1
    Registered User
    Join Date
    01-08-2020
    Location
    Worcester, England
    MS-Off Ver
    2016
    Posts
    35

    Runtime Error 5 Invalid Procedure Call or Argument

    Afternoon Excel Forum!

    I posted back in January for some help to fine tune a Print to PDF macro. This went well and we have enjoyed using the functionality... until today, today I cannot fix the 'Runtime Error 5'

    I've posted my code below, the error is on:

    'Save as PDF
    ActiveSheet.ExportAsFixedFormat...

    Please Login or Register  to view this content.
    I've seen varying responses on Google, none that quite match what i'm trying to achieve and also struggling to understand what error Runtime 5 is!

    Any advice would be greatly appreciated

  2. #2
    Forum Expert romperstomper's Avatar
    Join Date
    08-13-2008
    Location
    East Sussex, UK
    MS-Off Ver
    365, varying versions/builds
    Posts
    21,332

    Re: Runtime Error 5 Invalid Procedure Call or Argument

    Are you sure that A19 on the active sheet contains a valid file name?
    Everyone who confuses correlation and causation ends up dead.

  3. #3
    Registered User
    Join Date
    01-08-2020
    Location
    Worcester, England
    MS-Off Ver
    2016
    Posts
    35

    Re: Runtime Error 5 Invalid Procedure Call or Argument

    It does indeed. I have it set to white text so users can't see it but it's definitely there.

  4. #4
    Registered User
    Join Date
    01-08-2020
    Location
    Worcester, England
    MS-Off Ver
    2016
    Posts
    35

    Re: Runtime Error 5 Invalid Procedure Call or Argument

    I did wonder if it might be because there is nothing to specify A19 in Sheets HSE052 Fall PPE Certificate, but this code has been working for a few months now.

  5. #5
    Forum Expert romperstomper's Avatar
    Join Date
    08-13-2008
    Location
    East Sussex, UK
    MS-Off Ver
    365, varying versions/builds
    Posts
    21,332

    Re: Runtime Error 5 Invalid Procedure Call or Argument

    You should add that:

    Please Login or Register  to view this content.

  6. #6
    Registered User
    Join Date
    01-08-2020
    Location
    Worcester, England
    MS-Off Ver
    2016
    Posts
    35

    Re: Runtime Error 5 Invalid Procedure Call or Argument

    Added the code in and re ran the macro, it returned with 'Run-time error' '9' Subscript out of range'

  7. #7
    Forum Expert romperstomper's Avatar
    Join Date
    08-13-2008
    Location
    East Sussex, UK
    MS-Off Ver
    365, varying versions/builds
    Posts
    21,332

    Re: Runtime Error 5 Invalid Procedure Call or Argument

    Based on your original code the sheet name starts with HS052 not HSE052, so you'll need to change that.

  8. #8
    Registered User
    Join Date
    01-08-2020
    Location
    Worcester, England
    MS-Off Ver
    2016
    Posts
    35

    Re: Runtime Error 5 Invalid Procedure Call or Argument

    I've just been reading the code again and spotted the same, now i'm back to the Runtime Error 5

  9. #9
    Forum Expert romperstomper's Avatar
    Join Date
    08-13-2008
    Location
    East Sussex, UK
    MS-Off Ver
    365, varying versions/builds
    Posts
    21,332

    Re: Runtime Error 5 Invalid Procedure Call or Argument

    What exactly is in A19?

  10. #10
    Registered User
    Join Date
    01-08-2020
    Location
    Worcester, England
    MS-Off Ver
    2016
    Posts
    35

    Re: Runtime Error 5 Invalid Procedure Call or Argument

    A19 is a concatenation of 3 cells within HS052 Fall PPE Certificate sheet. The formula reads '=CONCATENATE(H6," ",B6," ",F7)'

  11. #11
    Forum Expert romperstomper's Avatar
    Join Date
    08-13-2008
    Location
    East Sussex, UK
    MS-Off Ver
    365, varying versions/builds
    Posts
    21,332

    Re: Runtime Error 5 Invalid Procedure Call or Argument

    I mean what is the actual value in that cell when the error occurs?

  12. #12
    Registered User
    Join Date
    01-08-2020
    Location
    Worcester, England
    MS-Off Ver
    2016
    Posts
    35

    Re: Runtime Error 5 Invalid Procedure Call or Argument

    'sn 100551492 & sn 10551797 Spanset RA Harness with Adjustable Restraint Lanyard Pass' is the currently the result of the concatenate. Do you think this could be too long?

  13. #13
    Forum Expert romperstomper's Avatar
    Join Date
    08-13-2008
    Location
    East Sussex, UK
    MS-Off Ver
    365, varying versions/builds
    Posts
    21,332

    Re: Runtime Error 5 Invalid Procedure Call or Argument

    It's possible, particularly as that is quite a long folder path too. Test it with a short file name and see if that makes a difference.

  14. #14
    Registered User
    Join Date
    01-08-2020
    Location
    Worcester, England
    MS-Off Ver
    2016
    Posts
    35

    Re: Runtime Error 5 Invalid Procedure Call or Argument

    The spreadsheet works on a number of tabs:

    1. Harness Register
    2. Withdrawn from Service Register
    3. Thorough Inspection Form -- This is where the serial number is pasted into, from the Harness Register, to build the the Checklist and Certificate sheets
    4. HS052 Fall PPE Checklist
    5. HS052 Fall PPE Certificate

    I have just taken a shorter serial number and gone through the process of creating the certificate, used the macro and hey presto! it worked!

    I also did an =LEN( on 'sn 100551492 & sn 10551797 Spanset RA Harness with Adjustable Restraint Lanyard Pass' which came back as 83 characters, i think this is too long for a filename perhaps.

  15. #15
    Registered User
    Join Date
    01-08-2020
    Location
    Worcester, England
    MS-Off Ver
    2016
    Posts
    35

    Re: Runtime Error 5 Invalid Procedure Call or Argument

    Hurrah! That's worked wonderfully, thank you for your time and help rorya!

  16. #16
    Forum Expert romperstomper's Avatar
    Join Date
    08-13-2008
    Location
    East Sussex, UK
    MS-Off Ver
    365, varying versions/builds
    Posts
    21,332

    Re: Runtime Error 5 Invalid Procedure Call or Argument

    I think it's the combination of the file name and path being too long. Perhaps you could output them somewhere locally first, then move them later?

  17. #17
    Registered User
    Join Date
    03-22-2021
    Location
    Pakistan
    MS-Off Ver
    2016
    Posts
    1

    Re: Runtime Error 5 Invalid Procedure Call or Argument

    Invalid procedure call or argument (Error 5) excel
    how to resolve

  18. #18
    Forum Expert romperstomper's Avatar
    Join Date
    08-13-2008
    Location
    East Sussex, UK
    MS-Off Ver
    365, varying versions/builds
    Posts
    21,332

    Re: Runtime Error 5 Invalid Procedure Call or Argument

    Administrative Note:

    Welcome to the forum.

    We are happy to help, however whilst you feel your request is similar to this thread, experience has shown that things soon get confusing when answers refer to particular cells/ranges/sheets which are unique to your post and not relevant to the original.

    Please see Forum Rule #4 about hijacking and start a new thread for your query.

    If you are not familiar with how to start a new thread see the FAQ: How to start a new thread

+ 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. VBA Log function Runtime Error '5': Invalid procedure call or argument
    By asaiz in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 02-22-2019, 04:31 AM
  2. [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
  3. Help! Run-Time Error '5': Invalid procedure call or argument
    By capwork in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 02-18-2015, 08:10 PM
  4. [SOLVED] runtime error 5, invalid procedure call or argument ??
    By tintin007 in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 10-01-2014, 05:25 AM
  5. 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
  6. 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
  7. 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

Tags for this Thread

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