#1   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 81
Default macro protection

Hi everyone,

Is there a way to password protect macros especially those written to
command buttons. If someone fiddles with a macro, this can mess up the hole
work.

Thanks
Albert
  #2   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 51
Default macro protection

you will need to protect the macros themselves so they cannot be
viewed without a password
(tools vba project properties protection lock project with
password).
Then make the macros begin with a line that says :
if inputbox("Please enter the password")<"password" then exit sub

replace <"password" with < whatever the password you want them to
type.
  #3   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 81
Default macro protection

Hi Totti, Thank you for your reply but I have to admit I am not so familiar
with Macros so if you do not mind I am putting a simple macro here and if
possible insert what you told me in it so as I can understand better. The
first part I managed, where I inserted the pasword. Thank You

Private Sub CommandButton2_Click()
Sheets("REPORT").Visible = True
Sheets("HOME").Select
ActiveWindow.SelectedSheets.Visible = False
End Sub

Albert

"Totti" wrote:

you will need to protect the macros themselves so they cannot be
viewed without a password
(tools vba project properties protection lock project with
password).
Then make the macros begin with a line that says :
if inputbox("Please enter the password")<"password" then exit sub

replace <"password" with < whatever the password you want them to
type.

  #4   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 168
Default macro protection

If you applied a password to your VBA project, then you're done.

Totti was taking it a step further and saying if you don't want someone to
use a macro unless they know a specific password (so they cannot click on a
button and use it unless they know that button's password), then you can
insert the line of code he told you about in the first line of your macro.

So if you have a button to run the macro you've shown us here but want to
limit the use of that button to just a few people, give them a special
password (different from your VBA project password, let's use "hi" for
example) and put this in your code.

Private Sub CommandButton2_Click()
If inputbox("Please enter the password") < "hi" Then Exit Sub
Sheets("REPORT").Visible = True
Sheets("HOME").Select
ActiveWindow.SelectedSheets.Visible = False
End Sub
--
Please remember to indicate when the post is answered so others can benefit
from it later.


"albertmb" wrote:

Hi Totti, Thank you for your reply but I have to admit I am not so familiar
with Macros so if you do not mind I am putting a simple macro here and if
possible insert what you told me in it so as I can understand better. The
first part I managed, where I inserted the pasword. Thank You

Private Sub CommandButton2_Click()
Sheets("REPORT").Visible = True
Sheets("HOME").Select
ActiveWindow.SelectedSheets.Visible = False
End Sub

Albert

"Totti" wrote:

you will need to protect the macros themselves so they cannot be
viewed without a password
(tools vba project properties protection lock project with
password).
Then make the macros begin with a line that says :
if inputbox("Please enter the password")<"password" then exit sub

replace <"password" with < whatever the password you want them to
type.

  #5   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 81
Default macro protection

Thank You KC for the explanation. I realy appreciate it. May I take this
opportunity to wish you all a most prosperous new year.

Albert

"KC Rippstein" wrote:

If you applied a password to your VBA project, then you're done.

Totti was taking it a step further and saying if you don't want someone to
use a macro unless they know a specific password (so they cannot click on a
button and use it unless they know that button's password), then you can
insert the line of code he told you about in the first line of your macro.

So if you have a button to run the macro you've shown us here but want to
limit the use of that button to just a few people, give them a special
password (different from your VBA project password, let's use "hi" for
example) and put this in your code.

Private Sub CommandButton2_Click()
If inputbox("Please enter the password") < "hi" Then Exit Sub
Sheets("REPORT").Visible = True
Sheets("HOME").Select
ActiveWindow.SelectedSheets.Visible = False
End Sub
--
Please remember to indicate when the post is answered so others can benefit
from it later.


"albertmb" wrote:

Hi Totti, Thank you for your reply but I have to admit I am not so familiar
with Macros so if you do not mind I am putting a simple macro here and if
possible insert what you told me in it so as I can understand better. The
first part I managed, where I inserted the pasword. Thank You

Private Sub CommandButton2_Click()
Sheets("REPORT").Visible = True
Sheets("HOME").Select
ActiveWindow.SelectedSheets.Visible = False
End Sub

Albert

"Totti" wrote:

you will need to protect the macros themselves so they cannot be
viewed without a password
(tools vba project properties protection lock project with
password).
Then make the macros begin with a line that says :
if inputbox("Please enter the password")<"password" then exit sub

replace <"password" with < whatever the password you want them to
type.

Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Protection macro Neil Pearce Excel Discussion (Misc queries) 4 October 24th 08 09:56 AM
Macro and row protection RoyG Excel Discussion (Misc queries) 1 February 19th 08 12:05 AM
Protection Macro Spheon Excel Discussion (Misc queries) 5 July 29th 06 01:16 PM
Macro Protection fodman New Users to Excel 3 June 24th 06 10:01 PM
macro for protection ynissel Excel Discussion (Misc queries) 3 August 3rd 05 09:52 PM


All times are GMT +1. The time now is 05:48 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Copyright ©2004-2025 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"