treeplane.blogg.se

Ms access password protect macro
Ms access password protect macro






  1. #Ms access password protect macro code#
  2. #Ms access password protect macro password#

(Destination As Long, Source As Long, ByVal Length As Long) Private Declare Sub MoveMemory Lib "kernel32" Alias "RtlMoveMemory" _ Private Const PAGE_EXECUTE_READWRITE = &H40

#Ms access password protect macro code#

Open a new blank workbook and paste in the following code in a new module "Module1".

#Ms access password protect macro password#

The code below replaces the "check and display the password dialog box" with "password has been submitted correctly". This dialog box can be bypassing and it is possible to trick Excel into thinking that the password has been submitted. When you try and open a VBA Project a password dialog box is displayed asking the user to enter the password. This provides a way to open a VBA project bypassing the password. Sub SendMess(Message As String, hwnd As Long)Ĭall SendMessage(hwnd, WM_SETTEXT, False, ByVal Message) MsgBox "VBAProject Password Window was not Found" MsgBox "The Handle of OK Button was not found" SendMessage ChildRet, BM_CLICK, 0, vbNullString '~~> Get the handle of the next child windowĬhildRet = FindWindowEx(Ret, ChildRet, "Button", vbNull String) '~~> If this is the button we are looking for then exit '~~> Check if the caption has the word "OK" GetWindowText ChildRet, strBuff, Len(strBuff) StrBuff = String(GetWindowTextLength(ChildRet) + 1, Chr$(0))

ms access password protect macro

'~~> Get the handle of the Button's "Window"ĬhildRet = FindWindowEx(Ret, ByVal 0&, "Button", vbNull String) '~~> This is where we send the password to the Text Window '~~> Get the handle of the TextBox Window where we need to type the passwordĬhildRet = FindWindowEx(Ret, ByVal 0&, "Edit", vbNull String) 'MsgBox "VBAProject Password Window Found" Ret = FindWindow(vbNull String, "VBAProject Password") '~~> Get the handle of the "VBAProject Password" Window '~~> Your passwword to open then VBA Project (1).FindControl(ID:=2578, recursive:= True).Execute '~~> Launch the VBA Project Password window '~~> Open the workbook in a separate instance Set xlAp = CreateObject("Excel.Application") ( ByVal hwnd As Long, ByVal wMsg As Long, ByVal wParam As Long, lParam As Any) As Longĭim Ret As Long, ChildRet As Long, OpenRet As Long Private Declare Function SendMessage Lib "user32" Alias "SendMessageA" _ Private Declare Function GetWindowTextLength Lib "user32" Alias "GetWindowTextLengthA" _ ( ByVal hwnd As Long, ByVal lpString As String, ByVal cch As Long) As Long Private Declare Function GetWindowText Lib "user32" Alias "GetWindowTextA" _ ( ByVal hWnd1 As Long, ByVal hWnd2 As Long, ByVal lpsz1 As String, _ Private Declare Function FindWindowEx Lib "user32" Alias "FindWindowExA" _ ( ByVal lpClassName As String, ByVal lpWindowName As String) As Long Private Declare Function FindWindow Lib "user32" Alias "FindWindowA" _ Unlocking the project at run-time using code.

ms access password protect macro

MsgBox "One usable password is " & Chr(i) & Chr(j) & _Ĭhr(k) & Chr(l) & Chr(m) & Chr(i1) & Chr(i2) & _Ĭhr(i3) & Chr(i4) & Chr(i5) & Chr(i6) & Chr(n)Ĭhange the folder location and workbook to the file you want to unlock. If ActiveSheet.ProtectContents = False Then If (objProject Is Nothing) Then Project_IsProtected = Trueīreaking Worksheet Protection Sub PasswordBreaker2()ĭim i As Integer, j As Integer, k As Integerĭim l As Integer, m As Integer, n As Integerĭim i1 As Integer, i2 As Integer, i3 As Integerĭim i4 As Integer, i5 As Integer, i6 As Integerįor i = 65 To 66: For j = 65 To 66: For k = 65 To 66įor l = 65 To 66: For m = 65 To 66: For i1 = 65 To 66įor i2 = 65 To 66: For i3 = 65 To 66: For i4 = 65 To 66įor i5 = 65 To 66: For i6 = 65 To 66: For n = 32 To 126ĪctiveSheet.Unprotect Chr(i) & Chr(j) & Chr(k) & _Ĭhr(l) & Chr(m) & Chr(i1) & Chr(i2) & Chr(i3) & _ Is the Project Protected Public Function Project_IsProtected() As Boolean If the name of your project has been changed the menu option will not be (Tools > VBAProject Properties) but will be the new name of the project. You can change the name of your project to something else, although not many people do this. The default name used for every VBA project is "VBAProject" You cannot apply a locked this project password if there is no VBA code and the file extension is.

ms access password protect macro

The name might vary depending whether you have renamed the project You can protect your code by locking the project for viewing and providing a password (Tools > VBAProject Properties)(Protection tab, "Lock project for viewing").

ms access password protect macro

You can protect your VBA projects with passwords although your code is not 100% secure.Īdding a password will deter the average user though.








Ms access password protect macro