Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
Home
DiscussionsAccessExcelInfoPathOutlookPowerPointPublisherWord
DirectoryUser Groups
Related Topics
Outlook ExpressInternet ExplorerWindowsMS Server ProductsMore Topics ...

MS Office Forum / Excel / New Users / March 2008

Tip: Looking for answers? Try searching our database.

Password protect a macro

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
Crownman - 01 Mar 2008 22:40 GMT
Hello -

I have a workbook that contains several macros that I want only some
of the users to be able to run.  Is there some way that I can add code
to these macros that will require the user to enter a password in
order to get the macro to run?  Or is there some other way to
accomplish this?

TIA for any advice.

Crownman
Gord Dibben - 01 Mar 2008 23:23 GMT
If the other users don't know the names of the macros you could lock the project
for viewing with a password.

Then "some users" could just enter the name of the macro in the dialog box at
Tools>Macro>Macros and run from there.

Or unlock the project to get a list of the macros to run.

As a back-up to the above you could code to password the macro from running.

Sub do_things()
Const pword As String = "secret"
         permit = InputBox("Enter the secret word")
              permit <> pword Then
                 MsgBox "not today, Wilbur"
         Exit Sub
    End If
MsgBox "you got it right"
End Sub

You would also have to lock project for viewing so's no unathorized user could
see the secret password.

Gord Dibben  MS Excel MVP

>Hello -
>
[quoted text clipped - 7 lines]
>
>Crownman
Bob Flanagan - 02 Mar 2008 13:05 GMT
To protect the password from being seen, you can create a userform with a
TextBox and specify "*" as the password character for the TextBox.  When the
person types in the password, all tha apprears are *'s.

Bob Flanagan
Macro Systems
http://www.add-ins.com
Productivity add-ins and downloadable books on VB macros for Excel

> Hello -
>
[quoted text clipped - 7 lines]
>
> Crownman
Crownman - 02 Mar 2008 13:45 GMT
> To protect the password from being seen, you can create a userform with a
> TextBox and specify "*" as the password character for the TextBox.  When the
[quoted text clipped - 17 lines]
>
> - Show quoted text -

Thank you both for your advice.  I figured out a workable solution by
making the macros Private Subs.  This hid them from the selection box
from Tools>Macro>Macro.  Then hiding the code from viewing will keep
unauthorized users from viewing the code.  I just have to make sure
that the authorized users know the macro names.

Crownman
Dave Peterson - 02 Mar 2008 14:50 GMT
After you add the top secret password check to each macro, you could give the
users an easier way to run them.

For additions to the worksheet menu bar, I really like the way John Walkenbach
does it in his menumaker workbook:
http://j-walk.com/ss/excel/tips/tip53.htm

Here's how I do it when I want a toolbar:
http://www.contextures.com/xlToolbar02.html
(from Debra Dalgleish's site)

And if you use xl2007:

If you want to learn about modifying the ribbon, you can start at Ron de Bruin's
site:
http://www.rondebruin.nl/ribbon.htm
http://www.rondebruin.nl/qat.htm  -- For macros for all workbooks (saved as an
addin)
or
http://www.rondebruin.nl/2007addin.htm

In xl2007, those toolbars and menu modifications will show up under the addins.

> Hello -
>
[quoted text clipped - 7 lines]
>
> Crownman

Signature

Dave Peterson


Rate this thread:






 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.