Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 6
Default Macro to open view with a password

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   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 2,836
Default Macro to open view with a password

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   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 2,836
Default Macro to open view with a password

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   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1,533
Default Macro to open view with a password

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
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Password protection in macro ( Anybody can view my password in VB Sherees Excel Discussion (Misc queries) 2 January 24th 10 10:05 PM
Open a workbook with a password via macro - How to? fishy Excel Discussion (Misc queries) 1 February 29th 08 02:21 PM
macro to open csv file on the web with password andycg Excel Programming 2 July 2nd 06 06:43 PM
Macro Password to open or access Param Excel Worksheet Functions 0 March 6th 06 04:24 PM
is there anyway to make it so the users of my excel spread sheet cant view the macro code w/o a password? Daniel Excel Worksheet Functions 2 June 28th 05 05:34 AM


All times are GMT +1. The time now is 02:38 AM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Copyright ©2004-2025 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"