View Single Post
  #1   Report Post  
Moselle Moselle is offline
Junior Member
 
Posts: 2
Default writerespassword is not working

below is my code. when i clock my macro button. it will automatically save my excel sheet but i can only open it with password. whenever i try to open it with my wrirespassword. it just prompt the CAPS LOCKs error. im new to excel and i totally have no idea why this happen when the password works well as i need to open it in writeable version with wrirespassword. if i remove the password:= and just used the wrirespassword. it will auto save as open excel without encrypt anything. please help me on this :(


Sub SaveInvWithNewName()
Dim NewFN As String
' Copy Invoice to a new workbook
ActiveSheet.Unprotect 111
ActiveSheet.Copy
NewFN = "Users/cs/Desktop" & Range("E3").Value & ".xlsx"
ActiveWorkbook.SaveAs NewFN, FileFormat _
:=xlNormal, Password:="222", WriteResPassword:="333", _
ReadOnlyRecommended:=False, CreateBackup:=False
ActiveWorkbook.Close
NextInvoice
ActiveSheet.Protect 111

End Sub