Excel Unlocker
Excel Unlocker
Option Base 1
Sub GeneralSub()
CopiedExcel = False
RenamedZIP = False
CreatedTMPFolder = False
''Close WorkBook
tmpWB.Close saveChanges:=False
Set tmpWB = Nothing
''Vba-----------------------------------
If Sheet1.CheckVBA.Value = True And FSO.GetExtensionName(Fname) = "xlsm" Then
'Check whether WorkBook has VBA Project protection
If ProjectProtected = True Then
''WorkSheet----------------------------
If Sheet1.CheckWS.Value = True Then
If WBookSheetsProtected = True Then
End If
End Sub
CopyFname = rename_to_zip(name_of_exel_file)
''TMP Folder
FileNameFolder = create_TMP_folder
''Set to false
ProjectFileFound = False
Else
ChangePasswordForVBA = "File don't have VbaProject!"
End If
Application.StatusBar = ""
End Function
LockedWBName = copy_excel_file(Fname)
''Open Locked WB
On Error Resume Next ''Prevent error for WriteProtection Password
Set lockedWB = Workbooks.Open(LockedWBName, notify:=False, WriteResPassword:="",
UpdateLinks:=False, IgnoreReadOnlyRecommended:=True)
On Error GoTo 0
''Sort
UL.Worksheets("hash_table").AutoFilter.Sort.SortFields.Clear
UL.Worksheets("hash_table").AutoFilter.Sort.SortFields.Add Key:= _
Range("B1:B32769"), SortOn:=xlSortOnValues, Order:=xlAscending, DataOption _
:=xlSortNormal
With UL.Worksheets("hash_table").AutoFilter.Sort
.Header = xlYes
.MatchCase = False
.Orientation = xlTopToBottom
.SortMethod = xlPinYin
.Apply
End With
s_t = GetTickCount
ETR = 0
For i = 2 To 32769
DoEvents
Application.StatusBar = "WB Protection password guessing: " & Format((i / 32769), "0%") & " / Max
ETR: " & Format(TimeSerial(0, 0, ETR), "hh:mm:ss")
s_t = GetTickCount
End If
Next i
Loop Until 1 = 1
''Save WB
lockedWB.Close saveChanges:=True
Application.StatusBar = ""
Application.DisplayAlerts = True
Application.ScreenUpdating = True
End Function
Function UnprotectWSheets(Fname As Variant) As String ''Fname As Variant
Application.ScreenUpdating = False
Next i
For i = 1 To UBound(ProtectedSheets)
Application.StatusBar = "Sheets Protection / removing protection of " & "sheet" & ProtectedSheets(i)
Next i
DoEvents
Application.Wait (Now + TimeValue("0:00:01"))
Loop Until Err.Number = 0
On Error GoTo 0
'Keep script waiting until Compressing is done
On Error Resume Next
Do Until oApp.Namespace(CopyFname & "\xl\worksheets").items.Item("sheet" & ProtectedSheets(i) &
".xml").Name = CStr("sheet" & ProtectedSheets(i) & ".xml")
DoEvents
Application.Wait (Now + TimeValue("0:00:01"))
Loop
On Error GoTo 0
Next i
Application.StatusBar = ""
End Function
MODULE NAME: auxiliaryFuncs
Option Base 1
VBC = -1
On Error Resume Next
VBC = wb.VBProject.VBComponents.Count
On Error GoTo 0
If VBC = -1 Then
ProtectedVBProject = True
Else
ProtectedVBProject = False
End If
End Function
PrWB = False
End Function
PrWSheets = False
End Function
Function copy_excel_file(file_to_copy)
copy_excel_file = ""
Exit Function
End If
On Error GoTo 0
'Save flag
CopiedExcel = True
End If
''return path
copy_excel_file = UnprotecedFilePath
End Function
Function rename_to_zip(file_to_rename)
''Return path
rename_to_zip = ZIPFilePath
End Function
Function create_TMP_folder()
DoEvents
Application.Wait (Now + TimeValue("0:00:01")) '' wait until deletion is done
Loop
'Destroy FSO
Set FSO = Nothing
'Set Flag
CreatedTMPFolder = True
End If
create_TMP_folder = FileNameFolder
End Function
ReDim PasswordArrayByte(Len(HASHPassword))
.Close
End With
'save to file
adoBin.SaveToFile PathToBinFile, 2 'adSaveCreateOverWrite
adoBin.Close
.Close
End With
End Function
'Sub Auto_Open()
'
''''Add ADO library if required---------------------------------------------
''ADOAssigned = False
''
''For i = 1 To ThisWorkbook.VBProject.References.Count
'' ''Debug.Print ThisWorkbook.VBProject.References.Item(i).Name
'' If ThisWorkbook.VBProject.References.Item(i).Name = "ADODB" Then
'' ADOAssigned = True
'' End If
''Next i
''
''If ADOAssigned = False Then
'' ThisWorkbook.VBProject.References.AddFromFile Environ("CommonProgramFiles") &
"\System\ado\msado15.dll"
''End If
'
'
'End Sub