Consulting

Results 1 to 13 of 13

Thread: Disable SAVE/SAVE AS and Make Savable Again after Username and Password

  1. #1

    Disable SAVE/SAVE AS and Make Savable Again after Username and Password

    Hello Everyone,
    Hoping someone can help me out with this. I’ve disabled the SAVE and SAVE AS in my workbook. When the user tries to save, they are given a YES or No option. If YES is selected a LOGIN Form appears asking for a username and password. Everything works up until this part. What I can’t figure out is how to make the workbook savable again after the username and password has been supplied. Also, once changes are made and the workbook is closed, the process should start over when it reopens. Below is the code and I’ve attached the workbook. The username is hazmat and the password is 1012. Any assistance is greatly appreciated.

      Option Explicit
    Private Sub Workbook_BeforeSave(ByVal SaveAsUI As Boolean, Cancel As Boolean)
    Dim Ans As VbMsgBoxResult
    Ans = MsgBox("You can't save this workbook!" & vbNewLine & _
            "Do you have password to save the file?", vbQuestion + vbYesNo)
    If Ans = vbYes Then
        Frm_Login.Show   'UserForm to accept the password
    End If
     Cancel = True
    End Sub
    Attached Files Attached Files

  2. #2
    Why disabling in the first place ?
    When macros are designed properly it's fully redundant ( as is 'protection' in any form ).

  3. #3
    because it's going to be a shared file and i don't want anyone making changes to it.

  4. #4
    Then make it a read-only file.

  5. #5
    i have tried that, but with ready-only the user can still save as under a different file name. i don't want the user to have any save capability.

  6. #6
    the user can still save as under a different file name
    So what ?

  7. #7
    thanks for your help.

  8. #8
    if anyone knows how to do it, i'd greatly appreciate the help.

  9. #9
    VBAX Sage
    Joined
    Apr 2007
    Location
    United States
    Posts
    8,738
    Location
    Set an 'OK2Save' boolean variable

    But the whole approach is not very secure
    Attached Files Attached Files
    ---------------------------------------------------------------------------------------------------------------------

    Paul


    Remember: Tell us WHAT you want to do, not HOW you think you want to do it

    1. Use [CODE] ....[/CODE ] Tags for readability
    [CODE]PasteYourCodeHere[/CODE ] -- (or paste your code, select it, click [#] button)
    2. Upload an example
    Go Advanced / Attachments - Manage Attachments / Add Files / Select Files / Select the file(s) / Upload Files / Done
    3. Mark the thread as [Solved] when you have an answer
    Thread Tools (on the top right corner, above the first message)
    4. Read the Forum FAQ, especially the part about cross-posting in other forums
    http://www.vbaexpress.com/forum/faq...._new_faq_item3

  10. #10
    A user can always copy the contents of the file.

  11. #11
    VBAX Sage
    Joined
    Apr 2007
    Location
    United States
    Posts
    8,738
    Location
    Quote Originally Posted by snb View Post
    A user can always copy the contents of the file.

    Oh, there's SO many ways to bypass it
    ---------------------------------------------------------------------------------------------------------------------

    Paul


    Remember: Tell us WHAT you want to do, not HOW you think you want to do it

    1. Use [CODE] ....[/CODE ] Tags for readability
    [CODE]PasteYourCodeHere[/CODE ] -- (or paste your code, select it, click [#] button)
    2. Upload an example
    Go Advanced / Attachments - Manage Attachments / Add Files / Select Files / Select the file(s) / Upload Files / Done
    3. Mark the thread as [Solved] when you have an answer
    Thread Tools (on the top right corner, above the first message)
    4. Read the Forum FAQ, especially the part about cross-posting in other forums
    http://www.vbaexpress.com/forum/faq...._new_faq_item3

  12. #12
    If your company has Rights Management Service (RMS) setup you can prevent the user from doing all sorts of things depending on which templates have been set up for you (if any!):
    2020-11-04_11-46-36.jpg
    https://docs.microsoft.com/en-us/mic...o365-worldwide
    Regards,

    Jan Karel Pieterse
    Excel MVP jkp-ads.com

  13. #13
    I don't doubt it, but the people that will be viewing this workbook are not super excel savvy like you all. i'm not worried about anyone hacking or by passing the code. I just wanted to disable the basic save features, which this code seems to do. thank you again for the help and support. I appreciate your expertise.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •