golfnut324
Board Regular
- Joined
- Jul 12, 2006
- Messages
- 93
Very new to VBA here. I'm trying to put together a macro that will 1) Password protect all sheets in workbook, 2) Password protect the workbook, and 3) Save workbook with pre-determined name and then append the date and time to the name.
So far I've got the protect sheet (but not password protected) and save workbook with desired appended file name by using this code:
Private Sub Workbook_BeforeClose(Cancel As Boolean)
Sheets("Sheet1").Protect ("password")
End Sub
Private Sub Workbook_Open()
Sheets("Sheet1").Protect ("password")
End Sub
Sub Macro6()
'
' Macro6 Macro
'
' Keyboard Shortcut: Ctrl+w
'
'DIM Today As Date
Today = Date
Time = Time
ActiveSheet.Protect DrawingObjects:=True, Contents:=True, Scenarios:=True _
, AllowSorting:=True, AllowFiltering:=True
ChDir "C:\Users\Craig\Desktop"
ActiveWorkbook.SaveAs Filename:="tblContacts" & Format(Today, "_MMDDYYYY") & Format(Time, "_HHMM")
End Sub
I suspect that I've mixed some apples and oranges here. Can anyone steer me in the right direction. I'm determined to learn this somehow
Craig
So far I've got the protect sheet (but not password protected) and save workbook with desired appended file name by using this code:
Private Sub Workbook_BeforeClose(Cancel As Boolean)
Sheets("Sheet1").Protect ("password")
End Sub
Private Sub Workbook_Open()
Sheets("Sheet1").Protect ("password")
End Sub
Sub Macro6()
'
' Macro6 Macro
'
' Keyboard Shortcut: Ctrl+w
'
'DIM Today As Date
Today = Date
Time = Time
ActiveSheet.Protect DrawingObjects:=True, Contents:=True, Scenarios:=True _
, AllowSorting:=True, AllowFiltering:=True
ChDir "C:\Users\Craig\Desktop"
ActiveWorkbook.SaveAs Filename:="tblContacts" & Format(Today, "_MMDDYYYY") & Format(Time, "_HHMM")
End Sub
I suspect that I've mixed some apples and oranges here. Can anyone steer me in the right direction. I'm determined to learn this somehow
Craig