Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8170281
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 6, 20262026-06-06T21:06:06+00:00 2026-06-06T21:06:06+00:00

Down below is my function, for some reason it does not work. If I

  • 0

Down below is my function, for some reason it does not work. If I place a breakpoint in the last if statement and removes sending “%{F11}” it does work. So my guess is that “%F11” is not working. Does anyone have an idea?

Sub UnprotecPassword(wb As Workbook, ByVal projectPassword As String)
    Dim currentActiveWb As Workbook    

    If wb.VBProject.Protection <> vbext_pp_locked Then
        Exit Sub
    End If
    Set currentActiveWb = ActiveWorkbook
    wb.Activate

    SendKeys "%{F11}"
    SendKeys "^r" ' Set focus to Explorer
    SendKeys "{TAB}" ' Tab to locked project
    SendKeys "~" ' Enter
    SendKeys projectPassword
    SendKeys "~" ' Enter

    If (wb.VBProject.Protection = vbext_pp_locked) Then
        MsgBox ("failed to unlock")
    End If
    currentActiveWb.Activate
End Sub
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-06T21:06:07+00:00Added an answer on June 6, 2026 at 9:06 pm

    To test this, Let’s create a new workbook called Book2.xlsm.

    for testing purpose paste this code in the Book2 Module.

    Sub Book2Macro()
    
    End Sub
    

    Protect it with a password say a and then close it. This is necessary for the Locking to take effect.

    Now create a new workbook say Book1 and in the module paste this code.

    Sub Sample()
        UnprotecPassword Workbooks("Book2.xlsm"), "a"
    End Sub
    
    Sub UnprotecPassword(wb As Workbook, ByVal projectPassword As String)
        Dim currentActiveWb As Workbook
    
        If wb.VBProject.Protection <> 1 Then
            Exit Sub
        End If
    
        Set currentActiveWb = ActiveWorkbook
    
        wb.Activate
    
        SendKeys "%{F11}"
        SendKeys "^r" ' Set focus to Explorer
        SendKeys "{TAB}" ' Tab to locked project
        SendKeys "~" ' Enter
        SendKeys projectPassword
        SendKeys "~" ' Enter
    
        If (wb.VBProject.Protection = vbext_pp_locked) Then
            MsgBox ("failed to unlock")
        End If
        currentActiveWb.Activate
    End Sub
    

    Now open the 1st workbook that we created; Book2.xlsm. Check the VBA Editor for Book2 and you will notice that it is password protected. You will also notice that it is the active workbook. Activate Book1 by clicking the View Tab | Switch Workbooks | Book1

    enter image description here

    Now click on Developer tab | Macros If you can’t see Developer tab then I would recommend going through this link.

    enter image description here

    Click on the the Sample Macro in the Macro Dialog Box and you are done.

    enter image description here

    If you check the VBA Editor, you will notice that the VBA Editor for Book2 is now unlocked/accessible.

    Sendkeys are unreliable depending on your use of it. If you use it correctly then that are pretty much reliable 🙂

    There is one more way to unlock the VBA Password but that is pretty complex and involves invoking the API like FindWindow etc…

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Below is a cut down example of some c# code I can't get to
I have a drop down box and some text input fields below it. Based
If i change the Spinner width like below only the up/down arrow place is
I'm having some trouble executing the slideDown() function in the code below. I'm using
For some reason I am unable to use query results in the same function
I am using jquery to slide up an down a div. For some reason
I get the following error when I try and execute the code down below.
In my email regex i want following output abc@abc.co.in I am writing down below
I have a link which once hovered over a box below slides down, once
New programmer here, I am trying to understand and break down this code below

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.