Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 141
Default Password Protect Running of Macro

Is it possible to Password protect the running of a Macro

I have a Macro that I only want certain people to be able to Run, I have
created the Macro but before it runs / executes I would like a dialog box to
pop up with a required password input, If the password is incorrect the
action is just cancelled

Thanks


  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 141
Default Password Protect Running of Macro

Did a search of Groups and spotted this neat code to do what I require

Sub PasswordForAMacro()
Dim Message As String, Title As String
Dim MyValue As String
Message = "Please enter your password to access this"
Title = "Run Macro"
MyValue = InputBox(Message, Title, Default)
If MyValue < "1234" Then
MsgBox "Invalid password - you cannot access this"
Exit Sub
Else
'type the actions / code you require to run'

ActiveSheet.Range("A1").Select
End If
End Sub






"John" wrote in message
...
Is it possible to Password protect the running of a Macro

I have a Macro that I only want certain people to be able to Run, I have
created the Macro but before it runs / executes I would like a dialog box
to pop up with a required password input, If the password is incorrect the
action is just cancelled

Thanks




  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 141
Default Password Protect Running of Macro

Is there an input mask that will enter the Password as **** instead of 1234?

I will be accessing this log on lineso a user in the remote location might
see the password I type in


"John" wrote in message
...
Did a search of Groups and spotted this neat code to do what I require

Sub PasswordForAMacro()
Dim Message As String, Title As String
Dim MyValue As String
Message = "Please enter your password to access this"
Title = "Run Macro"
MyValue = InputBox(Message, Title, Default)
If MyValue < "1234" Then
MsgBox "Invalid password - you cannot access this"
Exit Sub
Else
'type the actions / code you require to run'

ActiveSheet.Range("A1").Select
End If
End Sub






"John" wrote in message
...
Is it possible to Password protect the running of a Macro

I have a Macro that I only want certain people to be able to Run, I have
created the Macro but before it runs / executes I would like a dialog box
to pop up with a required password input, If the password is incorrect
the action is just cancelled

Thanks






  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 7,247
Default Password Protect Running of Macro

You can't do that with an inputbox. You'd need a userform with a
textbox whose PasswordChar property set to "*".

--
Cordially,
Chip Pearson
Microsoft MVP - Excel
Pearson Software Consulting, LLC
www.cpearson.com


"John" wrote in message
...
Is there an input mask that will enter the Password as ****
instead of 1234?

I will be accessing this log on lineso a user in the remote
location might see the password I type in


"John" wrote in message
...
Did a search of Groups and spotted this neat code to do what I
require

Sub PasswordForAMacro()
Dim Message As String, Title As String
Dim MyValue As String
Message = "Please enter your password to access this"
Title = "Run Macro"
MyValue = InputBox(Message, Title, Default)
If MyValue < "1234" Then
MsgBox "Invalid password - you cannot access this"
Exit Sub
Else
'type the actions / code you require to run'

ActiveSheet.Range("A1").Select
End If
End Sub






"John" wrote in message
...
Is it possible to Password protect the running of a Macro

I have a Macro that I only want certain people to be able to
Run, I have created the Macro but before it runs / executes I
would like a dialog box to pop up with a required password
input, If the password is incorrect the action is just
cancelled

Thanks








  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 31
Default Password Protect Running of Macro

How would one set up the routine to provide a usertform rather than an input
box then?

Gazza

"Chip Pearson" wrote in message
...
You can't do that with an inputbox. You'd need a userform with a textbox
whose PasswordChar property set to "*".

--
Cordially,
Chip Pearson
Microsoft MVP - Excel
Pearson Software Consulting, LLC
www.cpearson.com


"John" wrote in message
...
Is there an input mask that will enter the Password as **** instead of
1234?

I will be accessing this log on lineso a user in the remote location
might see the password I type in


"John" wrote in message
...
Did a search of Groups and spotted this neat code to do what I require

Sub PasswordForAMacro()
Dim Message As String, Title As String
Dim MyValue As String
Message = "Please enter your password to access this"
Title = "Run Macro"
MyValue = InputBox(Message, Title, Default)
If MyValue < "1234" Then
MsgBox "Invalid password - you cannot access this"
Exit Sub
Else
'type the actions / code you require to run'

ActiveSheet.Range("A1").Select
End If
End Sub






"John" wrote in message
...
Is it possible to Password protect the running of a Macro

I have a Macro that I only want certain people to be able to Run, I
have created the Macro but before it runs / executes I would like a
dialog box to pop up with a required password input, If the password is
incorrect the action is just cancelled

Thanks












  #6   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default Password Protect Running of Macro


The original subroutine would have to read:
Sub PasswordForAMacro()
Userform1.Show
End Sub

You would need a userform (called Userform1) with a text box (calle
Textbox1 with PasswordChar property set to "*") and a button (calle
Button1) to submit the userform. Then put the following code in th
userform

Sub Button1_Click()
If Textbox1.text < "1234" Then
MsgBox "Invalid password - you cannot access this"
Userform1.Hide
Exit Sub
Else
'type the actions / code you require to run'
Userform1.Hide
End I

--
r.bell321Posted from - http://www.officehelp.i

  #7   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default Password Protect Running of Macro


I don't know a way, but I know a workaround

Say the password was bob12, at the start of your subroutine you coul
have the line

If InputBox("Enter password") = "bob12" Then
etc....
end if

THis would prompt for a password. You would then have to protect you
VBAProject to stop people seeing this

--
r.bell321Posted from - http://www.officehelp.i

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
Macro to allow auto filter after running password protect Roady Excel Discussion (Misc queries) 1 July 17th 08 06:34 PM
Password for Running the Macro Naveen Excel Discussion (Misc queries) 3 July 13th 07 03:08 PM
Password Protect Macro? ryanmhess Excel Programming 4 January 27th 06 04:56 PM
Add protect worksheet password in macro Kelly Excel Worksheet Functions 1 January 10th 06 02:08 AM
Password protect macro Pete Excel Programming 2 April 16th 04 03:44 AM


All times are GMT +1. The time now is 05:38 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"