This doesn't currently work in Openpyxl (v2.4.8) - the password is not written to the output file. There is an open PR for this (https://bitbucket.org/openpyxl/openpyxl/pull-requests/180/read-and-write-workbook-protection/diff), so hopefully it will be included in future releases.