Step 2: Click on "Insert > Module and enter the following code;
module word
Sub test()
Dim i As Long
i = 0
Dim FileName As String
Application.FileDialog(msoFileDialogOpen).Show
FileName = Application.FileDialog(msoFileDialogOpen).SelectedItems(1)
ScreenUpdating = False
Line2: On Error GoTo Line1
Documents.Open FileName, , True, , i & ""
MsgBox "Password is " & i
Application.ScreenUpdating = True
Exit Sub
Line1: i = i + 1
Resume Line2
ScreenUpdating = True
End Sub
Step 3: Hit "F5" on your keyboard to run the code.
Step 4: Now select the locked Word file and open it. After a while, the password will appear and you can use it to unlock the document.