sharky12345
Well-known Member
- Joined
- Aug 5, 2010
- Messages
- 3,404
- Office Version
- 2016
- Platform
- Windows
I'm trying to save a copy of the activeworkbook as an xlsx macro free file, read only and protected but I can't get this to work:
It saves the file, but I'm getting an error 424 Object Required on this line:
Can anyone advise what the problem is?
VBA Code:
SaveName = Left$(ThisWorkbook.Name, InStrRev(ThisWorkbook.Name, ".") - 1) & " (Read Only).xlsx"
ActiveWorkbook.SaveCopyAs Filename:=ThisWorkbook.Path & "\" & SaveName
SavedFile = ThisWorkbook.Path & "\" & SaveName
SavedFile.Protect Structure:=True, Windows:=False, Password:=""
VBA.SetAttr ThisWorkbook.Path & "\" & SaveName, vbNormal
It saves the file, but I'm getting an error 424 Object Required on this line:
VBA Code:
SavedFile.Protect Structure:=True, Windows:=False, Password:="password"
Can anyone advise what the problem is?