+ Reply to Thread
Results 1 to 12 of 12

Runtime error 1004 with my saveas code

  1. #1
    Forum Contributor
    Join Date
    07-06-2012
    Location
    Bitola,Macedonia
    MS-Off Ver
    Excel 2007
    Posts
    132

    Runtime error 1004 with my saveas code

    Hello this code was working perfect and today has stoped. I don't know why it is showing runtime error 1004

    Please Login or Register  to view this content.
    Last edited by Anto_BT; 05-26-2015 at 10:58 AM.

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

    Re: Runtime error 1004 with my saveas code

    What's the error message?
    If posting code please use code tags, see here.

  3. #3
    Forum Guru TMS's Avatar
    Join Date
    07-15-2010
    Location
    The Great City of Manchester, NW England ;-)
    MS-Off Ver
    MSO 2007,2010,365
    Posts
    47,995

    Re: Runtime error 1004 with my saveas code

    Have you added any new worksheets to the workbook? What is in cell V1 in each of the worksheets? Are the characters valid in a file name? Does it contain a date? Does the file already exist?

    Might be helpful to provide a sample workbook based on the live file.

    Regards, TMS
    Trevor Shuttleworth - Retired Excel/VBA Consultant

    I dream of a better world where chickens can cross the road without having their motives questioned

    'Being unapologetic means never having to say you're sorry' John Cooper Clarke


  4. #4
    Forum Contributor
    Join Date
    07-06-2012
    Location
    Bitola,Macedonia
    MS-Off Ver
    Excel 2007
    Posts
    132

    Re: Runtime error 1004 with my saveas code

    Untitled.jpg
    this is the message

  5. #5
    Forum Contributor
    Join Date
    07-06-2012
    Location
    Bitola,Macedonia
    MS-Off Ver
    Excel 2007
    Posts
    132

    Re: Runtime error 1004 with my saveas code

    No there is not new worksheet, on V1 is always the same "05.2015". The folder exist yes!

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

    Re: Runtime error 1004 with my saveas code

    When you get the error is the worksheet you are trying to save as a new workbook named 175CAC20?

    What format do you want to save the new workbook? eg xlsm, xlsx

  7. #7
    Forum Contributor
    Join Date
    07-06-2012
    Location
    Bitola,Macedonia
    MS-Off Ver
    Excel 2007
    Posts
    132

    Re: Runtime error 1004 with my saveas code

    Now the name needs to be "SheetName_05.2015" I want to save in xlsx.

    Thank you for helping

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

    Re: Runtime error 1004 with my saveas code

    Does this work?
    Please Login or Register  to view this content.
    PS Is D a mapped/network drive?

  9. #9
    Forum Contributor
    Join Date
    07-06-2012
    Location
    Bitola,Macedonia
    MS-Off Ver
    Excel 2007
    Posts
    132

    Re: Runtime error 1004 with my saveas code

    D is Local Disk and it is not working your code

  10. #10
    Forum Guru TMS's Avatar
    Join Date
    07-15-2010
    Location
    The Great City of Manchester, NW England ;-)
    MS-Off Ver
    MSO 2007,2010,365
    Posts
    47,995

    Re: Runtime error 1004 with my saveas code

    Try putting some Debug statements in. This will tell you what is happening; which sheet is being processed, the contents of cell V1 on the sheet, the full path of the file to be saved ... and how many sheets/files have been processed.

    Please Login or Register  to view this content.

    Output:

    Please Login or Register  to view this content.

    The routine, as it stands, works OK for me. Have V1 in cell v1 on Sheet1, V2 in cell v1 on Sheet2, V3 in cell v1 on Sheet3. If I run the subroutine a second time, it still works but it asks me if I want to replace the existing file, which is as expected.

    So, back to what's in the cell on each sheet? Which sheet fails? Is it the first one? Or has it processed some sheets before it fails? If it has processed some successfully, that would imply the hard disk and the folder/sub-folder structure is OK.


    Regards, TMS

  11. #11
    Forum Contributor
    Join Date
    07-06-2012
    Location
    Bitola,Macedonia
    MS-Off Ver
    Excel 2007
    Posts
    132

    Re: Runtime error 1004 with my saveas code

    Thank you very much to all for help, i just restarted computer and it was function.
    I don't know what was the problem.

  12. #12
    Forum Guru TMS's Avatar
    Join Date
    07-15-2010
    Location
    The Great City of Manchester, NW England ;-)
    MS-Off Ver
    MSO 2007,2010,365
    Posts
    47,995

    Re: Runtime error 1004 with my saveas code

    You're welcome. Thanks for the rep.

+ 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] Runtime Error '1004' Method 'SaveAs' of object'_Workbook Failed
    By Angsome in forum Excel Programming / VBA / Macros
    Replies: 6
    Last Post: 09-12-2014, 02:58 PM
  2. [SOLVED] 'Runtime Error 1004' when trying to Rename Worksheet using vba code
    By Raporter65 in forum Excel Programming / VBA / Macros
    Replies: 5
    Last Post: 03-28-2013, 07:43 PM
  3. [SOLVED] Range error in code, runs alone but not inside my full program, giving runtime error 1004
    By charizzardd in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 08-23-2012, 03:34 PM
  4. Runtime Error Code 1004
    By laks in forum Excel Programming / VBA / Macros
    Replies: 11
    Last Post: 01-19-2007, 07:08 PM
  5. Replies: 4
    Last Post: 05-04-2006, 08:00 AM

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