Jump to content

Recommended Posts

Posted

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.

  • 7 months later...
  • Moderators
Posted

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)
Posted

#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!
  • 4 months later...
Posted

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

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 account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...