after searching all over the internet I could not find or for the life of me figure out how to Unprotect the whole workbook or just enter the password on Workbook_Open so that the Workbook remains password protected after exit. There is already a code I found that makes the .xlsm dependable on another file put in the system. Now I need for some extra security for all the work I put in the project, to make it impossible to open the file with Google Sheets where all protection drops and all my project is visible.
All separate sheets are password protected, one of them is also hidden.
Before Close there is a line with ThisWorkbook.Protect Password:=”Test”
I tried using ThisWorkbook.Unprotect Password:=”Test” in the Workbook_Open sub with no joy – Every time
“Run-time Error 1004…
This is the code at the moment:
Sub Workbook_Open()
Dim strFileName As String
Dim strFileExists As String
CurWkbkPath = ActiveWorkbook.FullName
CurWkbk = ActiveWorkbook.Name
strFileName = "TheNeededFilePath"
strFileExists = Dir(strFileName)
If strFileExists = "" Then
Windows(CurWkbk).Close
Else
Windows(CurWkbk).Activate
End If
End Sub
Stoyan Goshev is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.