+ Reply to Thread
Results 1 to 5 of 5

run-time error '5' excel

  1. #1
    Registered User
    Join Date
    02-03-2010
    Location
    Dhaka
    MS-Off Ver
    Excel 2003
    Posts
    14

    run-time error '5' excel

    Hi All,

    I want to create backup of my working folder. after the folder is copied I would like to set the name of the folder like "FE-26 DAILY FX POSITION-" & Current Date-1 & Current Month & Current Year. I want to set "date part" of the folder name (or rename) as "dd-mm-yyyy".

    I am running the following code:
    Please Login or Register  to view this content.
    After running the code I got run-time error '5' - Invalid Procedure Call or Argument. When I want to debug the code, I found the value of the variable "mDate" is "Empty"

    I want the backup folder for the date 14 Feb 2010 to be named as, FE-26 DAILY FX POSITION-14 02 2010
    Please help to resolve the problem
    Last edited by DonkeyOte; 02-15-2010 at 05:55 AM. Reason: update ... MOD EDIT: remedied code tags

  2. #2
    Forum Guru DonkeyOte's Avatar
    Join Date
    10-22-2008
    Location
    Northumberland, UK
    MS-Off Ver
    O365
    Posts
    21,531

    Re: run-time error '5' excel

    A few points:

    Please Login or Register  to view this content.

    in VBA with the above statement only dDate is declared as a Date type all others will be Variants... all variables must be explicitly declared (via As) if they are not intended to be Variants.
    (also I don't think you really want the last three to be Date values anyway)

    "mm" & "dd" are not valid DatePart values - you would need m & d

    The equivalent of Today() in VBA is Date ... you don't need to use Now.

    Given you're only using the date to formalise your present date string I would suggest just using:

    Please Login or Register  to view this content.
    Last edited by DonkeyOte; 02-15-2010 at 06:07 AM.

  3. #3
    Registered User
    Join Date
    02-03-2010
    Location
    Dhaka
    MS-Off Ver
    Excel 2003
    Posts
    14

    Re: run-time error '5' excel

    Thank you for the reply.

    I am testing the code and revert to you

  4. #4
    Registered User
    Join Date
    02-03-2010
    Location
    Dhaka
    MS-Off Ver
    Excel 2003
    Posts
    14

    Re: run-time error '5' excel

    Quote Originally Posted by Rashed.R View Post
    Thank you for the reply.

    I am testing the code and revert to you
    I have tested the code. I am not getting the result what I want to. For Example, I want the backup folder for the date 15 Feb 2010 to be named as "FE-26 DAILY FX POSITION-15 02 2010" but the resultant folder name is "15-Feb-10". I am getting error in the code line:
    [CODE]
    Name OldName As NewName ' Rename file.
    [CODE]
    File Not found. I understand that since the file is renamed with the line of code
    [CODE]
    FSO.CopyFolder Source:=FromPath, Destination:=ToPath & Format(Date - 1, "DD-MMM-YY")
    The line of code
    [CODE]
    Name OldName As NewName ' Rename file.
    gives the 'File Not Found' Error.
    So can you please help me to set the folder name as I desire.

  5. #5
    Registered User
    Join Date
    02-03-2010
    Location
    Dhaka
    MS-Off Ver
    Excel 2003
    Posts
    14

    Re: run-time error '5' excel

    Quote Originally Posted by Rashed.R View Post
    Thank you for the reply.

    I am testing the code and revert to you
    I have tested the code. I am not getting the result what I want to. For Example, I want the backup folder for the date 15 Feb 2010 to be named as "FE-26 DAILY FX POSITION-15 02 2010" but the resultant folder name is "15-Feb-10". I am getting error in the below line of code:
    Please Login or Register  to view this content.
    File Not found. I understand that since the file is renamed with the below line of code
    Please Login or Register  to view this content.
    The below line of code
    Please Login or Register  to view this content.
    gives the 'File Not Found' Error.
    So can you please help me to set the folder name as I desire.
    Last edited by Rashed.R; 02-16-2010 at 07:01 AM. Reason: update

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

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