View Single Post
  #1   Report Post  
Posted to microsoft.public.excel.programming
Per Jessen Per Jessen is offline
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