You cannot Unprotect Sheets via VBA code on a shared workbook. Sorry, no way around that.
But instead of standard protection, you could modify your code to protect (while it's NOT shared) to use UserInterfaceOnly...
So UNShare the book..
Then remove any code in your book that Protects/unprotects sheets...
run a macro to protect all sheets you want protected using UserInterfaceOnly = TRUE
Sheets("Sheet1").Protect Password:="PasswordHere", UserInterfaceOnly:=True
Then reshare the workbook.
Now your VBA code can modify sheets, but users can't