ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Unlocking for viewing (in VBE) (https://www.excelbanter.com/excel-programming/360403-unlocking-viewing-vbe.html)

Edmund

Unlocking for viewing (in VBE)
 
Assuming all my passwords are "abc"

To unprotect my active sheet, I do€¦€¦
ActiveSheet.Unprotect €śabc€ť

To unprotect my write protected workbook, I do€¦€¦
Workbooks.Open Filename:=TargetPathAndName, WriteResPassword:= €śabc€ť

But to €śunlock for viewing€ť in VBE, my module1 under Project Name Book, what
the code like?

Many thanks


Bob Phillips[_14_]

Unlocking for viewing (in VBE)
 
It can be done, but it involves the use of SendKeys which isn't too stable.

This is an example, but you may need to tune it


With Application
.SendKeys "%{F11}", True ' VBE
.SendKeys "^r", True ' Set focus to Explorer
.SendKeys "{TAB}", True ' Tab to locked project
.SendKeys "~", True ' Enter
.SendKeys "password"
.SendKeys "~", True ' Enter
End With


--
HTH

Bob Phillips

(remove xxx from email address if mailing direct)

"Edmund" wrote in message
...
Assuming all my passwords are "abc"

To unprotect my active sheet, I do..
ActiveSheet.Unprotect "abc"

To unprotect my write protected workbook, I do..
Workbooks.Open Filename:=TargetPathAndName, WriteResPassword:= "abc"

But to "unlock for viewing" in VBE, my module1 under Project Name Book,

what
the code like?

Many thanks





All times are GMT +1. The time now is 06:07 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com