
(Destination As Long, Source As Long, ByVal Length As Long) Private Declare Sub MoveMemory Lib "kernel32" Alias "RtlMoveMemory" _ Private Const PAGE_EXECUTE_READWRITE = &H40 Open the file(s) that contain your locked VBA ProjectsĬreate a new xlsm file and store this code in Module1Ĭode credited to Siwtom (nick name), a Vietnamese developer Option Explicit.The code below swaps the memory of the original function used to display the password dialog with a user defined function that will always return 1 when being called.
if this value is 1, the VBE will "think" that the password is right, hence the locked VBA project will be opened. After the dialog box is closed, the VBE checks the returned value of the system function. If user enters the wrong password or click Cancel, this function returns 0. If user enters the right password and click OK, this function returns 1. The VBE will call a system function to create the password dialog box. I will try my best to explain how it works - please excuse my English. Looking for 64 bit version? See this answer How it works It will work for any files (*.xls, *.xlsm, *.xlam. You can try this direct VBA approach which doesn't require HEX editing.