Spiff59 Posted May 19, 2008 Share 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. Link to comment Share on other sites More sharing options...
Moderators big_daddy Posted May 20, 2008 Moderators Share 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 Link to comment Share on other sites More sharing options...
Spiff59 Posted May 21, 2008 Author Share 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. Link to comment Share on other sites More sharing options...
Shalm Posted January 17, 2009 Share 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! Link to comment Share on other sites More sharing options...
Moderators big_daddy Posted January 17, 2009 Moderators Share 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) Link to comment Share on other sites More sharing options...
Shalm Posted January 18, 2009 Share 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! Link to comment Share on other sites More sharing options...
symadis Posted June 14, 2009 Share 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 Link to comment Share on other sites More sharing options...
Juvigy Posted June 15, 2009 Share 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. Link to comment Share on other sites More sharing options...
Moderators big_daddy Posted June 17, 2009 Moderators Share Posted June 17, 2009 Workbook.Unprotect Method Link to comment Share on other sites More sharing options...
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