+ Reply to Thread
Results 1 to 15 of 15

Invalid procedure call or argument error for ExportAsFixedFormat

  1. #1
    Registered User
    Join Date
    03-17-2011
    Location
    Atlanta
    MS-Off Ver
    Excel for Office 365
    Posts
    38

    Invalid procedure call or argument error for ExportAsFixedFormat

    I received an invalid procedure call or argument when running this section of a Macro I've written to print out worksheets as a PDF. When running the script, the error occurs with the following section of code:

    Please Login or Register  to view this content.
    I am able to use the same Macro in a different workbook, but when I try to use it in the current one I am using, it errors out at this point in the execution.

    Any thoughts on how to fix it? Since it works in other files, I think it might be a setting I am overlooking.

    Note: mypath is defined as my desktop.

  2. #2
    Forum Expert
    Join Date
    02-11-2014
    Location
    New York
    MS-Off Ver
    Excel 365 (Windows)
    Posts
    6,275

    Re: Invalid procedure call or argument error for ExportAsFixedFormat

    Does mypath include a valid filename/extension?
    Bernie Deitrick
    Excel MVP 2000-2010

  3. #3
    Forum Expert Arkadi's Avatar
    Join Date
    02-13-2014
    Location
    Smiths Falls, Ontario, Canada
    MS-Off Ver
    Office 365
    Posts
    5,059

    Re: Invalid procedure call or argument error for ExportAsFixedFormat

    If mypath is your desktop, I assume it ends on "\" but you also need to provide some kind of name as well as a path?

    It sounds like you are trying to save a file with no name?
    Please help by:

    Marking threads as closed once your issue is resolved. How? The Thread Tools at the top
    Any reputation (*) points appreciated. Not just by me, but by all those helping, so if you found someone's input useful, please take a second to click the * at the bottom left to let them know

    There are 10 kinds of people in this world... those who understand binary, and those who don't.

  4. #4
    Registered User
    Join Date
    03-17-2011
    Location
    Atlanta
    MS-Off Ver
    Excel for Office 365
    Posts
    38

    Re: Invalid procedure call or argument error for ExportAsFixedFormat

    Here's the code I have to determine the file name and path:

    Please Login or Register  to view this content.
    The debug specifically highlights the section I first posted:

    Please Login or Register  to view this content.

  5. #5
    Registered User
    Join Date
    03-17-2011
    Location
    Atlanta
    MS-Off Ver
    Excel for Office 365
    Posts
    38

    Re: Invalid procedure call or argument error for ExportAsFixedFormat

    Oh you know what? I bet this is it: the physicians are listed first name, space, last name. So you're exactly right, it's not a valid file name! Thank you!

    EDIT: Well, maybe not. I took out the space and it still errors out at the same point.
    Last edited by physicsgal; 02-08-2019 at 02:36 PM. Reason: Not solved

  6. #6
    Forum Expert Arkadi's Avatar
    Join Date
    02-13-2014
    Location
    Smiths Falls, Ontario, Canada
    MS-Off Ver
    Office 365
    Posts
    5,059

    Re: Invalid procedure call or argument error for ExportAsFixedFormat

    Spaces are allowed in file names...

    What is the exact value of "mypath" when the error occurs? Does it happen on the very first Physician? Can you attach a sample workbook that generates the error? if it happens on the first line, that is probably all the data we need... modify names or other data if you like, but make sure it still does error out.

  7. #7
    Registered User
    Join Date
    03-17-2011
    Location
    Atlanta
    MS-Off Ver
    Excel for Office 365
    Posts
    38

    Re: Invalid procedure call or argument error for ExportAsFixedFormat

    "\\server.domain.local\Redirfolders\user\Desktop\First Last.pdf"

    I took out the sensitive pieces of information, but that is the structure of it.

  8. #8
    Forum Expert Arkadi's Avatar
    Join Date
    02-13-2014
    Location
    Smiths Falls, Ontario, Canada
    MS-Off Ver
    Office 365
    Posts
    5,059

    Re: Invalid procedure call or argument error for ExportAsFixedFormat

    No special characters in what you removed? in itself that looks fine to me.

  9. #9
    Forum Expert
    Join Date
    02-11-2014
    Location
    New York
    MS-Off Ver
    Excel 365 (Windows)
    Posts
    6,275

    Re: Invalid procedure call or argument error for ExportAsFixedFormat

    You should make sure your code is not trying to create a file that already exists:
    Please Login or Register  to view this content.
    Last edited by Bernie Deitrick; 02-08-2019 at 03:27 PM.

  10. #10
    Forum Expert Arkadi's Avatar
    Join Date
    02-13-2014
    Location
    Smiths Falls, Ontario, Canada
    MS-Off Ver
    Office 365
    Posts
    5,059

    Re: Invalid procedure call or argument error for ExportAsFixedFormat

    The section you first posted has nothing wrong with it ... i've tested it ant that's not giving errors.

  11. #11
    Registered User
    Join Date
    03-17-2011
    Location
    Atlanta
    MS-Off Ver
    Excel for Office 365
    Posts
    38

    Re: Invalid procedure call or argument error for ExportAsFixedFormat

    Yes, it does happen on the very first physician. There's a lot of proprietary/confidential information so I can't upload a sample quickly. I've run the same code in other files with no problem, so I am at a loss for it not working here. I might just blow away the code and start over, see if it was something somewhere else I did not catch. I simply started with where Excel told me the error occurred.

  12. #12
    Registered User
    Join Date
    03-17-2011
    Location
    Atlanta
    MS-Off Ver
    Excel for Office 365
    Posts
    38

    Re: Invalid procedure call or argument error for ExportAsFixedFormat

    Bernie, can you show me where? I thought this piece was changing the value of Physician throughout the loop:

    Please Login or Register  to view this content.

  13. #13
    Forum Expert
    Join Date
    02-11-2014
    Location
    New York
    MS-Off Ver
    Excel 365 (Windows)
    Posts
    6,275

    Re: Invalid procedure call or argument error for ExportAsFixedFormat

    Sorry I was running out to lunch and mis-read your code.

    Make sure your code is not trying to create a file that already exists:

    Please Login or Register  to view this content.

  14. #14
    Registered User
    Join Date
    03-17-2011
    Location
    Atlanta
    MS-Off Ver
    Excel for Office 365
    Posts
    38

    Re: Invalid procedure call or argument error for ExportAsFixedFormat

    I took out the code tied to exporting as a PDF and noticed when the worksheets are copied, the name is not being changed. Any thoughts on why?

  15. #15
    Forum Expert
    Join Date
    02-11-2014
    Location
    New York
    MS-Off Ver
    Excel 365 (Windows)
    Posts
    6,275

    Re: Invalid procedure call or argument error for ExportAsFixedFormat

    It could be the names are too long or have invalid characters: Try it like this:

    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)

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. ExportAsFixedFormat Invalid Procedure Call
    By harold-sih in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 07-24-2015, 12:26 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. 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
  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. [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
  7. [SOLVED] 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

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