Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default Password Protecting a particular Sub


Hi All,
I'm looking to put in some sort of protection that will require a
password to run a particluar sub in an excel file. The sub will be
attached to a button...

I had thought that I should pop up an input box (somehow!) and then
compare the input from the user to a defined constant in the code... is
this the best way, and if so, how do I write the input box code?

Here's the button code as it stands... it's nothing special!

Private Sub CommandButton4_Click()
Overduepdp
ProtectSheet
End Sub

Thanks all.

Gareth


--
pianoman
------------------------------------------------------------------------
pianoman's Profile: http://www.excelforum.com/member.php...o&userid=33712
View this thread: http://www.excelforum.com/showthread...hreadid=544564

  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default Password Protecting a particular Sub


Dim password As String
Private Sub CommandButton4_Click()
password = "clearannual"
Set passwordinput = Application.InputBox(prompt:="Input Password to
Clear Annual Dates", Type:=2)
If passwordinput = password Then
Overduepdp
ProtectSheet
Else
response = MsgBox("Incorrect Password Supplied. Please try again",
vbOKOnly, "Clear Annual dates Password")
End If
End Sub

Obviously it's not working yet...


--
pianoman
------------------------------------------------------------------------
pianoman's Profile: http://www.excelforum.com/member.php...o&userid=33712
View this thread: http://www.excelforum.com/showthread...hreadid=544564

  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 292
Default Password Protecting a particular Sub

In its simplest form

Private Sub CommandButton4_Click()
If InputBox("Password please:") < "Top Secret" Then Exit Sub
Overduepdp
ProtectSheet
End Sub

HTH. Best wishes Harald

"pianoman" skrev i
melding ...

Hi All,
I'm looking to put in some sort of protection that will require a
password to run a particluar sub in an excel file. The sub will be
attached to a button...

I had thought that I should pop up an input box (somehow!) and then
compare the input from the user to a defined constant in the code... is
this the best way, and if so, how do I write the input box code?

Here's the button code as it stands... it's nothing special!

Private Sub CommandButton4_Click()
Overduepdp
ProtectSheet
End Sub

Thanks all.

Gareth


--
pianoman
------------------------------------------------------------------------
pianoman's Profile:
http://www.excelforum.com/member.php...o&userid=33712
View this thread: http://www.excelforum.com/showthread...hreadid=544564



  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default Password Protecting a particular Sub


Magic Harald,
Works just fine.

Many thanks,

Gareth

Harald Staff Wrote:
In its simplest form

Private Sub CommandButton4_Click()
If InputBox("Password please:") < "Top Secret" Then Exit Sub
Overduepdp
ProtectSheet
End Sub

HTH. Best wishes Harald

"pianoman"
skrev i
melding ...

Hi All,
I'm looking to put in some sort of protection that will require a
password to run a particluar sub in an excel file. The sub will be
attached to a button...

I had thought that I should pop up an input box (somehow!) and then
compare the input from the user to a defined constant in the code...

is
this the best way, and if so, how do I write the input box code?

Here's the button code as it stands... it's nothing special!

Private Sub CommandButton4_Click()
Overduepdp
ProtectSheet
End Sub

Thanks all.

Gareth


--
pianoman

------------------------------------------------------------------------
pianoman's Profile:
http://www.excelforum.com/member.php...o&userid=33712
View this thread:

http://www.excelforum.com/showthread...hreadid=544564



--
pianoman
------------------------------------------------------------------------
pianoman's Profile: http://www.excelforum.com/member.php...o&userid=33712
View this thread: http://www.excelforum.com/showthread...hreadid=544564

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
Password Protecting a workbook Maryann Excel Discussion (Misc queries) 2 April 14th 10 03:10 PM
Password Protecting Nick Excel Discussion (Misc queries) 6 June 30th 05 12:06 PM
password protecting macros Saju S Excel Programming 1 September 29th 04 07:24 AM
Protecting Sheet with Password halem2[_20_] Excel Programming 3 September 17th 04 01:58 AM
Password Protecting a Macro Marino13 Excel Programming 1 January 6th 04 04:37 PM


All times are GMT +1. The time now is 08:00 AM.

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

About Us

"It's about Microsoft Excel"