+ Reply to Thread
Results 1 to 6 of 6

Macros that unprotect

  1. #1
    Forum Contributor
    Join Date
    08-15-2006
    Location
    USA
    MS-Off Ver
    Office 365, 64 bit
    Posts
    372

    Macros that unprotect

    I have a set of macros for an EXCEL program. Some of these 'unprotect' certain or multiple sheets for 'maintenance' purposes.

    I've protected the code, WB and each individual sheets. Even though they cannot edit the macro, anyone can run the macro from Tools/Macro/MAcros...

    Since the macros that unprotect are there, they can run these and unprotect. How can I avoid, hide these? Any ideas?

    Thanks.

  2. #2
    Forum Contributor
    Join Date
    03-13-2005
    Posts
    6,195
    Quote Originally Posted by rz6657
    I have a set of macros for an EXCEL program. Some of these 'unprotect' certain or multiple sheets for 'maintenance' purposes.

    I've protected the code, WB and each individual sheets. Even though they cannot edit the macro, anyone can run the macro from Tools/Macro/MAcros...

    Since the macros that unprotect are there, they can run these and unprotect. How can I avoid, hide these? Any ideas?

    Thanks.
    use a question message box for a password, and only unprotect if the password is given.

    example:
    myAnswer = InputBox("Authority required", "please supply password")
    MsgBox myAnswer ' to test


    hth
    ---
    Last edited by Bryan Hessey; 12-19-2006 at 08:47 PM.
    Si fractum non sit, noli id reficere.

  3. #3
    Forum Contributor
    Join Date
    11-20-2005
    Posts
    256
    Quote Originally Posted by rz6657
    I have a set of macros for an EXCEL program. Some of these 'unprotect' certain or multiple sheets for 'maintenance' purposes.

    I've protected the code, WB and each individual sheets. Even though they cannot edit the macro, anyone can run the macro from Tools/Macro/MAcros...

    Since the macros that unprotect are there, they can run these and unprotect. How can I avoid, hide these? Any ideas?

    Thanks.
    Hi rz6657,

    In addition to Bryan's good answer you can prevnt the macro's from showing up in the Tools/Macro/Macros... by putting --> Option Private Module <--at the top of the module where your code is.
    Thx
    Dave
    "The game is afoot Watson"

  4. #4
    Registered User
    Join Date
    09-20-2006
    Location
    Poland
    Posts
    46
    Quote Originally Posted by Desert Piranha
    In addition to Bryan's good answer you can prevnt the macro's from showing up in the Tools/Macro/Macros... by putting --> Option Private Module <--at the top of the module where your code is.
    You may also "protect" individual macros within the module with the Private keyword, i.e., Private Sub MySub(), or by adding Optional argument to a sub. Note also, that even if the macro is not visible on the list, user still can run it by typing manually its name. Private macros could aslo by assigned to Forms Buttons, Shapes that way.
    MS Excel Games Library and much more:
    http://www.dzikosoft.com/gmexcel

  5. #5
    Forum Contributor
    Join Date
    08-15-2006
    Location
    USA
    MS-Off Ver
    Office 365, 64 bit
    Posts
    372

    Macros that unprotect

    Quote Originally Posted by Bryan Hessey
    use a question message box for a password, and only unprotect if the password is given.

    example:
    myAnswer = InputBox("Authority required", "please supply password")
    MsgBox myAnswer ' to test


    hth
    ---
    I tried it but even if they don't provide the correct password, it still runs. What am i doing wrong?

  6. #6
    Forum Contributor
    Join Date
    09-28-2006
    Posts
    122
    you need to check the answer in the code, something like

    if MyAnswer <> "the password you have decided" then
    exit sub
    else
    run your unprotect routine
    endif

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

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