Home |
Search |
Today's Posts |
#1
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
I am trying to have a macro open a view on a worksheet and really want to
have the worksheet protected. If i set a worksheet password the user is prompted for it when they click on the macro button, is there any way i can inlcude the password in the macro? I would also like to protect the worksheet once the macro has been run. The macro is as follows. ActiveSheet.Unprotect ActiveWorkbook.CustomViews("2 - Monday View").Show ActiveSheet.Protect DrawingObjects:=True, Contents:=True, Scenarios:=True _ , AllowFormattingCells:=True, AllowFormattingColumns:=True, _ AllowFormattingRows:=True, AllowSorting:=True Range("L9").Select End Sub |
#2
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
Here is an example:
Make Sheet1 VeryHidden: Hit Alt+F11, go to Properties Visible 2-xlSheetVeryHidden Place this code in Module1: Sub Passwrd() Dim i_pwd As String i_pwd = InputBox("Please Enter Password to Unhide Sheet", "Unhide Sheet...") If i_pwd = "" Then Exit Sub End If '#1 Select Case (i_pwd) Case Is = "Sheet1" Worksheets("Sheet1").Visible = True Sheets("Sheet1").Select Case Else MsgBox "Incorrect password; no action taken.", vbInformation, _ "Unhide Sheet..." End Select Exit Sub Place this code in the Sheet named €˜ThisWorkbook (hit Alt+F11 to see this object): Private Sub Workbook_Open() Module1.Passwrd End Sub Good luck, Ryan--- "julief" wrote: I am trying to have a macro open a view on a worksheet and really want to have the worksheet protected. If i set a worksheet password the user is prompted for it when they click on the macro button, is there any way i can inlcude the password in the macro? I would also like to protect the worksheet once the macro has been run. The macro is as follows. ActiveSheet.Unprotect ActiveWorkbook.CustomViews("2 - Monday View").Show ActiveSheet.Protect DrawingObjects:=True, Contents:=True, Scenarios:=True _ , AllowFormattingCells:=True, AllowFormattingColumns:=True, _ AllowFormattingRows:=True, AllowSorting:=True Range("L9").Select End Sub |
#3
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
Here is an example:
Make Sheet1 VeryHidden: Hit Alt+F11, go to Properties Visible 2-xlSheetVeryHidden Place this code in Module1: Sub Passwrd() Dim i_pwd As String i_pwd = InputBox("Please Enter Password to Unhide Sheet", "Unhide Sheet...") If i_pwd = "" Then Exit Sub End If '#1 Select Case (i_pwd) Case Is = "Sheet1" Worksheets("Sheet1").Visible = True Sheets("Sheet1").Select Case Else MsgBox "Incorrect password; no action taken.", vbInformation, _ "Unhide Sheet..." End Select Exit Sub Place this code in the Sheet named €˜ThisWorkbook (hit Alt+F11 to see this object): Private Sub Workbook_Open() Module1.Passwrd End Sub Good luck, Ryan--- |
#4
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
Hi
Sure you can include a password in the code. Look at this: MyPassword = "JustMe" ActiveSheet.Unprotect Password:=MyPassword ActiveWorkbook.CustomViews("2 - Monday View").Show ActiveSheet.Protect Password:=MyPassword, DrawingObjects:=True, _ Contents:=True, Scenarios:=True, AllowFormattingCells:=True, _ AllowFormattingColumns:=True, AllowFormattingRows:=True, AllowSorting:=True Range("L9").Select Regards, Per "julief" skrev i meddelelsen ... I am trying to have a macro open a view on a worksheet and really want to have the worksheet protected. If i set a worksheet password the user is prompted for it when they click on the macro button, is there any way i can inlcude the password in the macro? I would also like to protect the worksheet once the macro has been run. The macro is as follows. ActiveSheet.Unprotect ActiveWorkbook.CustomViews("2 - Monday View").Show ActiveSheet.Protect DrawingObjects:=True, Contents:=True, Scenarios:=True _ , AllowFormattingCells:=True, AllowFormattingColumns:=True, _ AllowFormattingRows:=True, AllowSorting:=True Range("L9").Select End Sub |
Reply |
Thread Tools | Search this Thread |
Display Modes | |
|
|
![]() |
||||
Thread | Forum | |||
Password protection in macro ( Anybody can view my password in VB | Excel Discussion (Misc queries) | |||
Open a workbook with a password via macro - How to? | Excel Discussion (Misc queries) | |||
macro to open csv file on the web with password | Excel Programming | |||
Macro Password to open or access | Excel Worksheet Functions | |||
is there anyway to make it so the users of my excel spread sheet cant view the macro code w/o a password? | Excel Worksheet Functions |