YasserKhalil
Well-known Member
- Joined
- Jun 24, 2010
- Messages
- 852
I have searched but didn't find a way to put an external password on closed workbook. Suppose I have closed workbook named "Sample.xlm" .. and I am opening a workbook named "Test.xlm". Is there a code that enables me to put a password on the Sample.xlsm? I mean external password .. I tried the following but got error (method protect of object workbook failed)
** I was protecting the Sample workbook with Protect and Share Workbook and I have changed to UnShare. This was the problem of the error that appears.
Now the code is working but when opening the Sample workbook after running the code, I found it unprotected. I expect to get it protected.
Thanks advanced for help
Posted here too
VBA Code:
Sub Test()
Dim wb As Workbook
Set wb = Workbooks.Open(ThisWorkbook.Path & "\Sample.xlsm")
wb.Protect Password:="123"
wb.Close True
End Sub
** I was protecting the Sample workbook with Protect and Share Workbook and I have changed to UnShare. This was the problem of the error that appears.
Now the code is working but when opening the Sample workbook after running the code, I found it unprotected. I expect to get it protected.
Thanks advanced for help
Posted here too
Protect closed workbook with password
I have searched but didn't find a way to put an external password on closed workbook. Suppose I have closed workbook named "Sample.xlm" .. and I am opening a workbook named "Test.xlm". Is there a c...
stackoverflow.com