Hello,
I changed your code a bit. Even I do not like the sendkey method, but I don't get any other possibility in my mind to protect the VBA project.
Now the code is doing what it should. after running the code, the file needs to be saved, closed and reopened to have the protection finalised.
Sub Test()
SendKeys "%{F11}", True
Application.Wait (Now + TimeValue("0:00:02"))
SendKeys "%TE", True
Application.Wait (Now + TimeValue("0:00:02"))
SendKeys "{TAB 9}", True
Application.Wait (Now + TimeValue("0:00:02"))
SendKeys "{RIGHT}", True
Application.Wait (Now + TimeValue("0:00:02"))
SendKeys "{TAB 2}", True
Application.Wait (Now + TimeValue("0:00:02"))
SendKeys " ", True
Application.Wait (Now + TimeValue("0:00:02"))
SendKeys "{TAB 2}", True
Application.Wait (Now + TimeValue("0:00:02"))
SendKeys "craig", True
Application.Wait (Now + TimeValue("0:00:02"))
SendKeys "{TAB}", True
Application.Wait (Now + TimeValue("0:00:02"))
SendKeys "craig", True
Application.Wait (Now + TimeValue("0:00:02"))
SendKeys "{ENTER}", True
Application.Wait (Now + TimeValue("0:00:02"))
SendKeys "%{F4}", True
Application.Wait (Now + TimeValue("0:00:02"))
End Sub
Bookmarks