Spiff59 Posted May 19, 2008 Posted May 19, 2008 I've tried plugging password(s) into the Excel UDF BookOpen routine with no luck. Is there no way to unlock a protected Excel worksheet, modify a cell or two, and then relock the worksheet? Thanks.
Moderators big_daddy Posted May 20, 2008 Moderators Posted May 20, 2008 (edited) You need to call the Worksheet.Unprotect Method. Then before saving call the Worksheet.Protect Method. Edited May 20, 2008 by big_daddy
Spiff59 Posted May 21, 2008 Author Posted May 21, 2008 You need to call the Worksheet.Unprotect Method. Then before saving call the Worksheet.Protect Method.Thank you, Sir!I have another Excel question, but I guess it's best put into a seperate post.
Shalm Posted January 17, 2009 Posted January 17, 2009 You need to call the Worksheet.Unprotect Method. Then before saving call the Worksheet.Protect Method.I am sorry if this is a stupid question.. but how would I implement this into my script? Specifically, what would the syntax look like? I am attempting to unprotect a sheet, make some changes, and then protect it again when done. Thanks for any help you can give!
Moderators big_daddy Posted January 17, 2009 Moderators Posted January 17, 2009 I am sorry if this is a stupid question.. but how would I implement this into my script? Specifically, what would the syntax look like? I am attempting to unprotect a sheet, make some changes, and then protect it again when done. Thanks for any help you can give!#include <Excel.au3> $sFilePath = @ScriptDir & "\Test.xls" $sPassword = "Password" $oExcel = _ExcelBookOpen($sFilePath) With $oExcel.Activesheet .Unprotect($sPassword) ; Make your changes .Protect($sPassword) EndWith _ExcelBookSave($oExcel)
Shalm Posted January 18, 2009 Posted January 18, 2009 #include <Excel.au3> $sFilePath = @ScriptDir & "\Test.xls" $sPassword = "Password" $oExcel = _ExcelBookOpen($sFilePath) With $oExcel.Activesheet .Unprotect($sPassword) ; Make your changes .Protect($sPassword) EndWith _ExcelBookSave($oExcel)Thank you, thank you!! Now that I see it, its seems so easy.. the syntax was eluding me. Thank you again!
symadis Posted June 14, 2009 Posted June 14, 2009 Hi , Thank you for this code it's working fine to unprotect the active sheet. Can you tell me what is the good syntax for unprotect the workbook too? I think that it should be the Workbook.Unprotect Method or Workbook.UnprotectDocument but I have no idea of the syntax. Thank you for your help Loris
Juvigy Posted June 15, 2009 Posted June 15, 2009 You can check the syntax on the MSDN page where you can find the Excel object model and the VBA reference.
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now