G Guest Jul 6, 2005 #1 Is there a way of setting up a password, so if the save button is pressed a password is needed before the program can be saved.
Is there a way of setting up a password, so if the save button is pressed a password is needed before the program can be saved.
G Guest Jul 6, 2005 #2 Also people. I am trying to write some code so when a button in my program is pressed it exits without saving. I have - ActiveWorksheet.Close I can not figure out what to put next, nothing I seem to wite is working
Also people. I am trying to write some code so when a button in my program is pressed it exits without saving. I have - ActiveWorksheet.Close I can not figure out what to put next, nothing I seem to wite is working
D Dave Peterson Jul 6, 2005 #3 The easy question. You could have a button (from the Forms toolbar) that looks like this: Option Explicit Sub testme() ThisWorkbook.Close savechanges:=False End Sub Or maybe... Option Explicit Sub testme() Dim Resp As Long Resp = MsgBox(prompt:="Are you sure you want to close without saving?", _ Buttons:=vbYesNo) If Resp = vbYes Then ThisWorkbook.Close savechanges:=False Else MsgBox "whew, that was close!" End If End Sub ============= As for saving only with a password... Put this under the ThisWorkbook module. Option Explicit Private Sub Workbook_BeforeSave(ByVal SaveAsUI As Boolean, Cancel As Boolean) Dim myPWD As String Dim Resp As String myPWD = "hithere" Resp = InputBox(prompt:="what's the password, Kenny?") If Resp = myPWD Then 'case sensitive! Cancel = False Else MsgBox "Can't save without the password" Cancel = True End If End Sub
The easy question. You could have a button (from the Forms toolbar) that looks like this: Option Explicit Sub testme() ThisWorkbook.Close savechanges:=False End Sub Or maybe... Option Explicit Sub testme() Dim Resp As Long Resp = MsgBox(prompt:="Are you sure you want to close without saving?", _ Buttons:=vbYesNo) If Resp = vbYes Then ThisWorkbook.Close savechanges:=False Else MsgBox "whew, that was close!" End If End Sub ============= As for saving only with a password... Put this under the ThisWorkbook module. Option Explicit Private Sub Workbook_BeforeSave(ByVal SaveAsUI As Boolean, Cancel As Boolean) Dim myPWD As String Dim Resp As String myPWD = "hithere" Resp = InputBox(prompt:="what's the password, Kenny?") If Resp = myPWD Then 'case sensitive! Cancel = False Else MsgBox "Can't save without the password" Cancel = True End If End Sub