View Single Post
 
Old 06-13-2017, 11:01 PM
gmayor's Avatar
gmayor gmayor is offline Windows 10 Office 2016
Expert
 
Join Date: Aug 2014
Posts: 4,137
gmayor has much to be proud ofgmayor has much to be proud ofgmayor has much to be proud ofgmayor has much to be proud ofgmayor has much to be proud ofgmayor has much to be proud ofgmayor has much to be proud ofgmayor has much to be proud ofgmayor has much to be proud of
Default

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
Reply With Quote