Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

unlock-lock sendkey help

112 views
Skip to first unread message

Dan L

unread,
Jan 10, 2002, 12:13:32 PM1/10/02
to
I figured I could takle my earlier question with sendkeys, since its
the only way to hand it.
I would like to unprotect my vba code, then run a macros named
ChangePW(), save, then reprotect the vba code without the user seeing
the vba screen.

I'm not familiar with sendkey's in excel 97 so I hope someone is able
to help me with this. I looked around and came up with (someone
else's code, did not find author's name):

Sub UnlockVBAProject()
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" ' project password
.SendKeys "~", True ' Enter
End With
Application.Run "ChangePW"
ActiveWorkbook.Save
reprotect the vba?
End Sub

I think when I tried to run this, it input the "password" right into a
cell in excel.

Thankyou,
Daniel

Bill Manville

unread,
Jan 13, 2002, 7:36:19 PM1/13/02
to
Dan L wrote:
> I think when I tried to run this, it input the "password" right into a
> cell in excel.
>

If you ran it from the Visual Basic Editor it would have done.
(Alt+F11 would take you back to Excel)

I don't believe you can avoid the user seeing the VB editor window at
least briefly while unprotecting the project.

Bill Manville
MVP - Microsoft Excel, Oxford, England
No email replies please - reply in newsgroup

0 new messages