![]() |
|
|
|
#1
|
||||
|
||||
|
Why not to use the button to prompt for the macro and only allow the code associated with the button to run if the password is entered? Code:
Private Sub CommandButton12_Click()
Const sPassword As String = "password"
Dim sAnswer As String
sAnswer = InputBox("Enter Password")
If Not sAnswer = (sPassword) Then
MsgBox "This function is not available without the correct password."
GoTo lbl_Exit
End If
'Do stuff e.g
MsgBox "Button code runs"
lbl_Exit:
Exit Sub
End Sub
__________________
Graham Mayor - MS MVP (Word) (2002-2019) Visit my web site for more programming tips and ready made processes www.gmayor.com |
|
| Thread Tools | |
| Display Modes | |
|
|
Similar Threads
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
Email from Command Button
|
derajlance | Word VBA | 6 | 05-05-2016 07:40 AM |
| Help with a Command Button | dkohnken | Word VBA | 5 | 03-18-2015 10:13 PM |
| command button query | smalc | Word VBA | 2 | 03-16-2015 08:26 PM |
| Command Button | knp11 | PowerPoint | 2 | 01-18-2015 01:41 PM |
Command Button
|
cksm4 | Word VBA | 7 | 02-27-2011 08:47 PM |