+ Reply to Thread
Results 1 to 5 of 5

Protect Workbook

  1. #1
    Registered User
    Join Date
    07-08-2015
    Location
    Enschede, Netherlands
    MS-Off Ver
    2010
    Posts
    3

    Protect Workbook

    For my job I have built a macro that needs to be monkey-proof protected, so no one can add information or make any changes to the file, except for those with the password.

    I have found some codes that protect the workbook from save, save as and ctrl+s mode to save over the original file. But the Inputbox isn't solid, by the Cancel button and the Esc key.

    What I need, is a VBA-code I cannot find on the internet and really have no knowledge of writing myself. The code for: File, Save As, Tools, General Options, Password when Open, Read Only recommended. Can anyone please help me out?!

  2. #2
    Valued Forum Contributor
    Join Date
    03-24-2014
    Location
    England
    MS-Off Ver
    Excel 2003 - 2016
    Posts
    575

    Re: Protect Workbook

    in the VBA window you'll see various items listed in the projects window, find the section called 'Microsoft Excel Objects' for your workbook and expand it, scroll to the bottom and you'll see an object called 'ThisWorkbook'.

    Open it up and you'll see a blank white sheet, there'll be 2 drop down menus at the top. Select 'Workbook' in the left hand one and then in the right you'll have all kinds of options to view. Each item in the right hand drop down box is an event that you can put code it.

    For example, you could put the command 'cancel = true' in the 'before_save' event and then no user will be able to save it. And yes, the problem with that is then you can't save it......so you'd need to put in something like

    Please Login or Register  to view this content.
    You can do the same for all kinds of events like double clicking, etc. To disable the ESC key put

    Please Login or Register  to view this content.
    in the workbook_open event. Remember to enable it again on workbook close though....

  3. #3
    Registered User
    Join Date
    07-08-2015
    Location
    Enschede, Netherlands
    MS-Off Ver
    2010
    Posts
    3

    Re: Protect Workbook

    Thank you for the quick reaction! I will give it a try!

  4. #4
    Valued Forum Contributor
    Join Date
    03-24-2014
    Location
    England
    MS-Off Ver
    Excel 2003 - 2016
    Posts
    575

    Re: Protect Workbook

    Graag gedaan

  5. #5
    Registered User
    Join Date
    07-08-2015
    Location
    Enschede, Netherlands
    MS-Off Ver
    2010
    Posts
    3

    Re: Protect Workbook

    The code works!!

    I used:

    Please Login or Register  to view this content.

+ 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. How to protect desired area of workbook and protect code.
    By avveerkar in forum Excel General
    Replies: 4
    Last Post: 01-12-2006, 10:44 PM
  2. [SOLVED] Passwords Disappear in OpenOffice (Protect Worksheet, and Protect Workbook)
    By msnews.microsoft.com in forum Excel General
    Replies: 6
    Last Post: 12-27-2005, 04:20 AM
  3. [SOLVED] Disable Tools, Protect, Protect Workbook
    By Paul Moles in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 09-05-2005, 11:05 AM
  4. Replies: 5
    Last Post: 08-09-2005, 11:05 AM
  5. Replies: 2
    Last Post: 07-16-2005, 11:05 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