+ Reply to Thread
Results 1 to 5 of 5

SaveAs 1004 Error

  1. #1
    Registered User
    Join Date
    03-20-2014
    Location
    United Kingdom
    MS-Off Ver
    Excel 2007
    Posts
    62

    SaveAs 1004 Error

    Hi

    I'm trying to save a workbook with a name related to a cell using the following code: -

    Sub Savepath()

    Dim FPATH As String
    FPATH = "T:\PERSONAL FOLDERS\STEVO56\ILS Test Rig Phase 1\Test Spreadsheet Dump\"
    ActiveWorkbook.SaveAs FPATH & Range("R5").value & ".XLSM", FileFormat:=52

    End Sub

    When the macro runs, it saves perfectly as required, however if a file already exists with that name the excel prompt asking to overwrite Yes/No/Cancel, yes works fine but no and cancel display a Run-time error'1004': Method 'SaveAs' of object'_Workbook' failed.

    If you select No or Cancel I would just like it to exit the sub.

    Any help would be appreciated, Thanks in advance.

    Steve

  2. #2
    Forum Guru HaHoBe's Avatar
    Join Date
    02-19-2005
    Location
    Hamburg, Germany
    MS-Off Ver
    2019 on Win10 (desktop), 2019 on Win11 (notebook)
    Posts
    8,099

    Re: SaveAs 1004 Error

    Hi, Steve,

    please wrap your procedure with code-tags as requested in Forum Rule #3.

    Ciao,
    Holger
    Use Code-Tags for showing your code: [code] Your Code here [/code]
    Please mark your question Solved if there has been offered a solution that works fine for you

  3. #3
    Registered User
    Join Date
    03-20-2014
    Location
    United Kingdom
    MS-Off Ver
    Excel 2007
    Posts
    62

    Re: SaveAs 1004 Error

    Hi

    I'm trying to save a workbook with a name related to a cell using the following code: -

    Please Login or Register  to view this content.
    When the macro runs, it saves perfectly as required, however if a file already exists with that name the excel prompt asking to overwrite Yes/No/Cancel, yes works fine but no and cancel display a Run-time error'1004': Method 'SaveAs' of object'_Workbook' failed.

    If you select No or Cancel I would just like it to exit the sub.

    Any help would be appreciated, Thanks in advance.

    Steve

  4. #4
    Forum Guru HaHoBe's Avatar
    Join Date
    02-19-2005
    Location
    Hamburg, Germany
    MS-Off Ver
    2019 on Win10 (desktop), 2019 on Win11 (notebook)
    Posts
    8,099

    Re: SaveAs 1004 Error

    Hi, Steve,

    you could have edited the opening post instead of repeating the post.

    IŽd go a different way:
    Please Login or Register  to view this content.
    Ciao,
    Holger

  5. #5
    Registered User
    Join Date
    03-20-2014
    Location
    United Kingdom
    MS-Off Ver
    Excel 2007
    Posts
    62

    Re: SaveAs 1004 Error

    Thanks Holger, that worked brilliantly, I really appreciate your 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. Replies: 8
    Last Post: 02-19-2014, 09:55 AM
  2. SaveAs Error 1004 when replacing
    By yawnzzzz in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 04-30-2013, 10:39 AM
  3. getting run time error 424 or 1004 when using Saveas method
    By Anchal in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 04-12-2013, 03:37 AM
  4. Run Time Error '1004': Method 'saveas' of object '_workbook' failed
    By vcuphysics in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 05-21-2012, 04:50 PM
  5. error 1004 Method SaveAs of Workbook failed
    By Maury Markowitz in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 10-25-2005, 04: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