+ Reply to Thread
Results 1 to 12 of 12

File is getting corrupted when saved / Invalid Procedure call or Argument Error

  1. #1
    Registered User
    Join Date
    10-11-2018
    Location
    Bangalore
    MS-Off Ver
    2016
    Posts
    10

    Exclamation File is getting corrupted when saved / Invalid Procedure call or Argument Error

    Hello Everyone,

    I'm new to VBA world. Please, could anyone help me?. Getting the message as Invalid procedure call or argument error and also after saving the file in output folder file is getting an error message. Attached zip folder for reference.

    Please Login or Register  to view this content.
    Moderator's note: Please take the time to review our rules. There aren't many, and they are all important. Rule #2 requires code tags. I have added them for you this time because you are a new member. --6StringJazzer
    Last edited by 6StringJazzer; 10-11-2018 at 12:20 PM. Reason: code tags

  2. #2
    Forum Moderator 6StringJazzer's Avatar
    Join Date
    01-27-2010
    Location
    Tysons Corner, VA, USA
    MS-Off Ver
    365
    Posts
    21,293

    Re: File is getting corrupted when saved / Invalid Procedure call or Argument Error

    What line of code is giving you the "Invalid procedure call or argument" error?

    I tried to run your code but I can't even start because the first thing it does is prompt me to open a file and I don't know what file to open.
    Jeff
    | | |?| |?| |?| |?| | |:| | |?| |?|
    Read the rules
    Use code tags to [code]enclose your code![/code]

  3. #3
    Registered User
    Join Date
    10-11-2018
    Location
    Bangalore
    MS-Off Ver
    2016
    Posts
    10

    Re: File is getting corrupted when saved / Invalid Procedure call or Argument Error

    Hi 6StringJazzer,

    sorry for that I'll make sure going forward.

    appreciate your quick response. it's my mistake I didn't explain it in brief. However, below are the steps which need to be followed:

    1. Firstly need to place the zipped folder in desktop and before running the Macro from the sheet("Blank_Checklist"), need to change the folder path in line "strFile = "C:\Users\pradeep_venugopal\Desktop\Insurance\Input\Input_Summary.xlsx"
    2. Need to open the file named "Insured_Name" when it prompts to open the file which is present inside Ins\New Requirement\

    The error message which I mentioned is in line " filename = Dir" and the error message I'm receiving is "Invalid Procedure call or Argument error.

    Also while saving the file due to the line("ActiveWorkbook.SaveAs "C:\Users\pradeep_venugopal\Desktop\Ins\New Requirement\Output\" & "LOB" & filename, xlNormal") which i have used it in my code is leading to file corrupt once copied into output folder.

    Please help me!!! thanking you in advance!!

  4. #4
    Forum Expert rorya's Avatar
    Join Date
    08-13-2008
    Location
    East Sussex, UK
    MS-Off Ver
    2016 primarily
    Posts
    7,413

    Re: File is getting corrupted when saved / Invalid Procedure call or Argument Error

    You can't call Dir inside another loop that uses Dir.
    Rory

  5. #5
    Registered User
    Join Date
    10-11-2018
    Location
    Bangalore
    MS-Off Ver
    2016
    Posts
    10

    Re: File is getting corrupted when saved / Invalid Procedure call or Argument Error

    Thank You, Rory. Could anyone please help me with the code. still, I couldn't figure out the alternate way. this is really been hectic for and I'm worried about it.

  6. #6
    Forum Expert rorya's Avatar
    Join Date
    08-13-2008
    Location
    East Sussex, UK
    MS-Off Ver
    2016 primarily
    Posts
    7,413

    Re: File is getting corrupted when saved / Invalid Procedure call or Argument Error

    Ideally you'd do your Dir loop at the start and put all the file names into an array and then process that. As a quick fix, you could add this function:

    Please Login or Register  to view this content.
    then replace this:

    Please Login or Register  to view this content.
    at the end of your function with this:

    Please Login or Register  to view this content.

  7. #7
    Registered User
    Join Date
    10-11-2018
    Location
    Bangalore
    MS-Off Ver
    2016
    Posts
    10

    Re: File is getting corrupted when saved / Invalid Procedure call or Argument Error

    Hi Rorya, I tried doing it in the same way as you said. unable to execute the function itself. could you please help me!!! Thanking you in advance!!

  8. #8
    Forum Expert rorya's Avatar
    Join Date
    08-13-2008
    Location
    East Sussex, UK
    MS-Off Ver
    2016 primarily
    Posts
    7,413

    Re: File is getting corrupted when saved / Invalid Procedure call or Argument Error

    What do you mean by that? You're not supposed to execute that function; it gets called by your existing code.

  9. #9
    Registered User
    Join Date
    10-11-2018
    Location
    Bangalore
    MS-Off Ver
    2016
    Posts
    10

    Re: File is getting corrupted when saved / Invalid Procedure call or Argument Error

    Hi Rorya,

    heartily thankful to you. It's working amazing the only thing is the file is getting corrupted when it's copied to the output folder, which is due to the below code I guess. could you please suggest me on this.

    Please Login or Register  to view this content.
    Note: Variable "filename" already consists of the filename with extension. (ex:LOB13 SBA IN4440 SB.xlsx). Not sure if this is correct.

  10. #10
    Forum Expert rorya's Avatar
    Join Date
    08-13-2008
    Location
    East Sussex, UK
    MS-Off Ver
    2016 primarily
    Posts
    7,413

    Re: File is getting corrupted when saved / Invalid Procedure call or Argument Error

    Replace xlNormal with xlOpenXMLWorkbook

  11. #11
    Registered User
    Join Date
    10-11-2018
    Location
    Bangalore
    MS-Off Ver
    2016
    Posts
    10

    Re: File is getting corrupted when saved / Invalid Procedure call or Argument Error

    Thanks a lot Rorya :-)

  12. #12
    Forum Expert rorya's Avatar
    Join Date
    08-13-2008
    Location
    East Sussex, UK
    MS-Off Ver
    2016 primarily
    Posts
    7,413

    Re: File is getting corrupted when saved / Invalid Procedure call or Argument Error

    Glad 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. Run time error 5, invalid procedure call or argument
    By arvimeld in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 08-06-2018, 09:11 AM
  2. [SOLVED] Run time error 5 - Invalid procedure call or argument
    By danbates in forum Excel General
    Replies: 2
    Last Post: 12-09-2017, 03:28 PM
  3. [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
  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. Run-time error 5, Invalid procedure call or argument
    By cmb80 in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 03-23-2014, 08:29 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. [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

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