+ Reply to Thread
Results 1 to 7 of 7

Macro for Document to "Save As"

  1. #1
    Registered User
    Join Date
    03-13-2017
    Location
    Virginia
    MS-Off Ver
    2013
    Posts
    34

    Macro for Document to "Save As"

    Hello. I would like some help in revising the below code. It is used to verify data before the document is saved. If data is incorrect, the user is given the choice to continue saving the file or they will be returned to the document to correct the invalid data I would like the "Save" to be changed to "Save As" so that the user can rename the document instead of automatically overwriting the existing one. Thank you.

    Please Login or Register  to view this content.

  2. #2
    Valued Forum Contributor spitfireblue's Avatar
    Join Date
    01-29-2015
    Location
    Adelaide, Australia
    MS-Off Ver
    2007,2010,2016
    Posts
    611

    Re: Macro for Document to "Save As"

    Please Login or Register  to view this content.
    Regards,
    Stephen

    If you feel someone has helped you please thank them and click on the star on their post to add reputation.
    Please ensure that you use code tags where relevant, and mark solved threads as solved.
    Most of all please be respectful and understanding of others.

  3. #3
    Registered User
    Join Date
    03-13-2017
    Location
    Virginia
    MS-Off Ver
    2013
    Posts
    34

    Re: Macro for Document to "Save As"

    Hello. Thank you for the quick response!

    I copied your code to the worksheet, and made a slight change by replacing the values A1 with B28 and B2 with B30. When I Save the spreadsheet I am not getting any message box even though B28 is TRUE and B30 is blank. Instead, the document is save without any kind of prompting. I have attached the spreadsheet if you're able to look at it. VBA is completely new to me and I could quite possibly be doing something wrong. Thank you.

    Please Login or Register  to view this content.

  4. #4
    Valued Forum Contributor spitfireblue's Avatar
    Join Date
    01-29-2015
    Location
    Adelaide, Australia
    MS-Off Ver
    2007,2010,2016
    Posts
    611

    Re: Macro for Document to "Save As"

    You need to place the macro in "This Workbook" not in "Sheet6"

  5. #5
    Registered User
    Join Date
    03-13-2017
    Location
    Virginia
    MS-Off Ver
    2013
    Posts
    34

    Re: Macro for Document to "Save As"

    I moved the code to "This Workbook," and it did the same thing as before, but I think I see the issue. If I click on the "X" to close and save the document, the message box pops up, but if I save by either going to File > Save or pressing Ctrl-S the document saves without a message box. Is it possible to get the message box no matter what method is used for saving and still give the user the choice to return to the document if they don't want to continue saving?

  6. #6
    Valued Forum Contributor spitfireblue's Avatar
    Join Date
    01-29-2015
    Location
    Adelaide, Australia
    MS-Off Ver
    2007,2010,2016
    Posts
    611

    Re: Macro for Document to "Save As"

    Yep, instead of using "Private Sub Workbook_BeforeClose(Cancel As Boolean)" you should use "Private Sub Workbook_BeforeSave(ByVal SaveAsUI As Boolean, Cancel As Boolean)"

  7. #7
    Registered User
    Join Date
    03-13-2017
    Location
    Virginia
    MS-Off Ver
    2013
    Posts
    34

    Re: Macro for Document to "Save As"

    It worked! Thank you so much for the 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. [SOLVED] Excel 2010 -- "Visual Basic" "Macros" and "Record Macro" all disabled.
    By NicholasL in forum Excel Programming / VBA / Macros
    Replies: 5
    Last Post: 05-07-2017, 06:11 AM
  2. Code To "Save As" And To Prompt To Enter A Password To Encrypt The Document?
    By npsnps in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 08-23-2016, 05:27 AM
  3. Need macro to disable "Save" and "Save as" buttons
    By Anforya in forum Excel Programming / VBA / Macros
    Replies: 10
    Last Post: 12-20-2013, 01:06 PM
  4. Excel opens "Save As" document preventing macro from looping
    By punkn00dlez in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 12-08-2010, 04:18 PM
  5. Forced to "save as" on closing document
    By Iokeef in forum Excel General
    Replies: 0
    Last Post: 02-24-2010, 09:57 AM
  6. Replies: 0
    Last Post: 08-07-2006, 01:35 AM
  7. [SOLVED] "Save as" will not work when trying to save a document in a folder
    By Ernest in forum Excel General
    Replies: 1
    Last Post: 04-13-2006, 01:48 AM

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