VB:This was to allow the macros to run on this protected sheet. The problem is when i set this workbook to Shared, opening it causes the error:Workbook_open() Dim sh As Worksheet Set sh = Sheets("Stats") sh.EnableAutoFilter = True sh.Protect contents:=True, userInterfaceOnly:=True, Password:="rats" End SubIf you like these VB formatting tags please consider sponsoring the author in support of injured Royal Marines
Private Sub Workbook_Open() ActiveWorkbook.UnprotectSharing SharingPassword:="mypass" ActiveWorkbook.Unprotect "mypass" Worksheets("Database").Visible = False With ActiveWorkbook If .MultiUserEditing Then Application.DisplayAlerts = False .ExclusiveAccess .Protect Structure:=False, Windows:=False .UnprotectSharing SharingPassword:="mypass" Application.DisplayAlerts = True End If End With With Worksheets("Visible") .EnableOutlining = True .Unprotect "mypass" .Protect Password:="mypass", UserInterfaceOnly:=True End With With ActiveWorkbook Application.DisplayAlerts = False .Protect "mypass", Structure:=True .SaveAs ActiveWorkbook.FullName ThisWorkbook.SaveAs Filename:=ThisWorkbook.FullName, Accessmode:=xlShared ProtectSharing Password:="mypass", SharingPassword:="mypass" Application.DisplayAlerts = True End With End Sub
Sub unprotect() a = InputBox("Please enter password") If a <> "mypass" Then MsgBox "Wrong password!" Worksheets("Database").Visible = False End If If a = "mypass" Then Application.DisplayAlerts = False ActiveWorkbook.UnprotectSharing SharingPassword:="mypass" Application.DisplayAlerts = True ActiveWorkbook.Unprotect "mypass" Worksheets("Database").Visible = True End If End SubThis macro is not working properly either. When running it displays numerous ERROR messages depending on the changes I make to the macro. It's very unstable and partially not working. So I hope to find someone with enough knowledge to help me solve the problem.
my macro code
all fine and dandy i checked this out to make sure it worked and sure did. As soon as i go and hit protect and share workbook and re-open the work book to test it out one more time for giggles i get an error. its a vba unprotect error? Is there any easy way around this? If i unprotect and unshare the workbook im good to go.. seems a pain in the butt for a simple sort if you ask me.
Sub Import() Dim wbkOpenClose As Workbook Dim wksINPUT As Worksheet Dim wbkCurrentFileLocation As Workbook Set wbkOpenClose = ActiveWorkbook Set wksINPUT = wbkOpenClose.Sheets("INPUT") Set wbkCurrentFileLocation = Workbooks.Open(Filename:=wksINPUT.Range("Current_File_Location").Value) wbkCurrentFileLocation.Close (False) End Sub