Pages - Menu

Rabu, 30 November 2011

Unprotect Sheet Excel


Rangkaian rumus-rumus di bawah ini adalah formula ampuh untuk membuka proteksi sheet (lembaran) dalam Excel yang dikunci dengan kata sandi (password). Saya mendapatkannya secara tidak sengaja ketika mencari file-file Excel di internet untuk koleksi pribadi. Tulis di module Visual Basic Editor lalu perintah / jalankan macro-nya dan tunggu beberapa saat hingga proses pembongkaran password selesai. Selamat mencoba.

Public Sub AllInternalPasswords()
' Breaks worksheet and workbook structure passwords. Bob McCormick
' probably originator of base code algorithm modified for coverage
' of workbook structure / windows passwords and for multiple passwords
'
' Norman Harker and JE McGimpsey 27-Dec-2002 (Version 1.1)
' Modified 2003-Apr-04 by JEM: All msgs to constants, and
' eliminate one Exit Sub (Version 1.1.1)
' Reveals hashed passwords NOT original passwords
Const DBLSPACE As String = vbNewLine & vbNewLine
Const AUTHORS As String = DBLSPACE & vbNewLine & _
"Adapted from Bob McCormick base code by" & _
"Norman Harker and JE McGimpsey"
Const HEADER As String = "AllInternalPasswords User Message"
Const VERSION As String = DBLSPACE & "Version 1.1.1 2003-Apr-04"
Const REPBACK As String = DBLSPACE & "Please report failure " & _
"to the microsoft.public.excel.programming newsgroup."
Const ALLCLEAR As String = DBLSPACE & "The workbook should " & _
"now be free of all password protection, so make sure you:" & _
DBLSPACE & "SAVE IT NOW!" & DBLSPACE & "and also" & _
DBLSPACE & "BACKUP!, BACKUP!!, BACKUP!!!" & _
DBLSPACE & "Also, remember that the password was " & _
"put there for a reason. Don't stuff up crucial formulas " & _
"or data." & DBLSPACE & "Access and use of some data " & _
"may be an offense. If in doubt, don't."
Const MSGNOPWORDS1 As String = "There were no passwords on " & _
"sheets, or workbook structure or windows." & AUTHORS & VERSION
Const MSGNOPWORDS2 As String = "There was no protection to " & _
"workbook structure or windows." & DBLSPACE & _
"Proceeding to unprotect sheets." & AUTHORS & VERSION
Const MSGTAKETIME As String = "After pressing OK button this " & _
"will take some time." & DBLSPACE & "Amount of time " & _
"depends on how many different passwords, the " & _
"passwords, and your computer's specification." & DBLSPACE & _
"Just be patient! Make me a coffee!" & AUTHORS & VERSION
Const MSGPWORDFOUND1 As String = "You had a Worksheet " & _
"Structure or Windows Password set." & DBLSPACE & _
"The password found was: " & DBLSPACE & "$$" & DBLSPACE & _
"Note it down for potential future use in other workbooks by " & _
"the same person who set this password." & DBLSPACE & _
"Now to check and clear other passwords." & AUTHORS & VERSION
Const MSGPWORDFOUND2 As String = "You had a Worksheet " & _
"password set." & DBLSPACE & "The password found was: " & _
DBLSPACE & "$$" & DBLSPACE & "Note it down for potential " & _
"future use in other workbooks by same person who " & _
"set this password." & DBLSPACE & "Now to check and clear " & _
"other passwords." & AUTHORS & VERSION
Const MSGONLYONE As String = "Only structure / windows " & _
"protected with the password that was just found." & _
ALLCLEAR & AUTHORS & VERSION & REPBACK
Dim w1 As Worksheet, w2 As Worksheet
Dim i As Integer, j As Integer, k As Integer, l As Integer
Dim m As Integer, n As Integer, i1 As Integer, i2 As Integer
Dim i3 As Integer, i4 As Integer, i5 As Integer, i6 As Integer
Dim PWord1 As String
Dim ShTag As Boolean, WinTag As Boolean

Application.ScreenUpdating = False
With ActiveWorkbook
WinTag = .ProtectStructure Or .ProtectWindows
End With
ShTag = False
For Each w1 In Worksheets
ShTag = ShTag Or w1.ProtectContents
Next w1
If Not ShTag And Not WinTag Then
MsgBox MSGNOPWORDS1, vbInformation, HEADER
Exit Sub
End If
MsgBox MSGTAKETIME, vbInformation, HEADER
If Not WinTag Then
MsgBox MSGNOPWORDS2, vbInformation, HEADER
Else
On Error Resume Next
Do 'dummy do loop
For i = 65 To 66: For j = 65 To 66: For k = 65 To 66
For l = 65 To 66: For m = 65 To 66: For i1 = 65 To 66
For i2 = 65 To 66: For i3 = 65 To 66: For i4 = 65 To 66
For i5 = 65 To 66: For i6 = 65 To 66: For n = 32 To 126
With ActiveWorkbook
.Unprotect Chr(i) & Chr(j) & Chr(k) & _
Chr(l) & Chr(m) & Chr(i1) & Chr(i2) & _
Chr(i3) & Chr(i4) & Chr(i5) & Chr(i6) & Chr(n)
If .ProtectStructure = False And _
.ProtectWindows = False Then
PWord1 = Chr(i) & Chr(j) & Chr(k) & Chr(l) & _
Chr(m) & Chr(i1) & Chr(i2) & Chr(i3) & _
Chr(i4) & Chr(i5) & Chr(i6) & Chr(n)
MsgBox Application.Substitute(MSGPWORDFOUND1, _
"$$", PWord1), vbInformation, HEADER
Exit Do 'Bypass all for...nexts
End If
End With
Next: Next: Next: Next: Next: Next
Next: Next: Next: Next: Next: Next
Loop Until True
On Error GoTo 0
End If
If WinTag And Not ShTag Then
MsgBox MSGONLYONE, vbInformation, HEADER
Exit Sub
End If
On Error Resume Next
For Each w1 In Worksheets
'Attempt clearance with PWord1
w1.Unprotect PWord1
Next w1
On Error GoTo 0
ShTag = False
For Each w1 In Worksheets
'Checks for all clear ShTag triggered to 1 if not.
ShTag = ShTag Or w1.ProtectContents
Next w1
If ShTag Then
For Each w1 In Worksheets
With w1
If .ProtectContents Then
On Error Resume Next
Do 'Dummy do loop
For i = 65 To 66: For j = 65 To 66: For k = 65 To 66
For l = 65 To 66: For m = 65 To 66: For i1 = 65 To 66
For i2 = 65 To 66: For i3 = 65 To 66: For i4 = 65 To 66
For i5 = 65 To 66: For i6 = 65 To 66: For n = 32 To 126
.Unprotect Chr(i) & Chr(j) & Chr(k) & _
Chr(l) & Chr(m) & Chr(i1) & Chr(i2) & Chr(i3) & _
Chr(i4) & Chr(i5) & Chr(i6) & Chr(n)
If Not .ProtectContents Then
PWord1 = Chr(i) & Chr(j) & Chr(k) & Chr(l) & _
Chr(m) & Chr(i1) & Chr(i2) & Chr(i3) & _
Chr(i4) & Chr(i5) & Chr(i6) & Chr(n)
MsgBox Application.Substitute(MSGPWORDFOUND2, _
"$$", PWord1), vbInformation, HEADER
'leverage finding Pword by trying on other sheets
For Each w2 In Worksheets
w2.Unprotect PWord1
Next w2
Exit Do 'Bypass all for...nexts
End If
Next: Next: Next: Next: Next: Next
Next: Next: Next: Next: Next: Next
Loop Until True
On Error GoTo 0
End If
End With
Next w1
End If
MsgBox ALLCLEAR & AUTHORS & VERSION & REPBACK, vbInformation, HEADER
End Sub

Jumat, 11 November 2011

Formula Tambahan


Di dalam buku Hisab Falak yang disusun oleh bapak H Ilya Asyhari Nawawi dari Bandungsari Grobogan, terdapat rumus Visual Basic Editor yang kompatibel untuk perangkat lunak Microsoft Excel. Fungsi dari rumus tersebut adalah untuk mengetahui diantaranya; awal waktu salat, arah kiblat dan rashdul kiblat. Namun, semenjak rumus itu ditulis sekitar sepuluh tahun yang lalu, nampaknya belum pernah direvisi ulang oleh penulis. Maklum, di PP Fadllul Wahid, materi ini tidak pernah diajarkan sama sekali.
Untuk rumus penentuan awal waktu salat, dalam buku itu hanya dirancang untuk Waktu Indonesia Barat (WIB) atau zona GMT+7. Padahal saat ini, berdasarkan keputusan Presiden Soeharto tahun 1988, Negara Kesatuan Republik Indonesia dibagi menjadi tiga zona waktu. Dengan ketentuan sebagai berikut; Waktu Indonesia Barat untuk pulau Sumatra, Jawa, Kalimantan Barat dan Kalimantan Tengah. Waktu Indonesia Tengah (WITA) untuk Bali, NTB, NTT, Kalsel, Kaltim dan Sulawesi. Waktu Indonesia Timur (WIT) untuk Gorontalo, Maluku dan Papua.
Maka dari itu, untuk bisa digunakan pada daerah-daerah yang berada di zona WITA atau WIT harus diedit sendiri dengan cara menambahkan function-function baru atau menambah argumen. Dan cara terakhirlah yang saya pilih karena lebih praktis.
Tulisan di bawah ini adalah kumpulan formula yang telah saya revisi agar bisa sesuai dengan seluruh daerah di Indonesia.

Function Tafaut1(Tgl, Bt, Markaz)
Tafaut1 = ((Bt - Markaz) / 15) - Tafaut(Tgl)
End Function

Function H_Sunset(Ard, Tgl, Ttmp)
Dekl = Mail(Tgl)
Sdm = Asinus(Sinus(-0.25) / Cosinus(Ard) / Cosinus(Dekl))
Refraksi = Asinus(Sinus(0 - 33 / 60 - 30 / 3600) / Cosinus(Ard) / Cosinus(Dekl))
Dip = -1.76 * Sqr(Ttmp) / 60
H_Sunset = Sdm + Refraksi + Dip
End Function

Function Terbit1(Ard, Bt, Tgl, Ttmp, Markaz)
Taf = Tafaut1(Tgl, Bt, Markaz)
Terbi = Terbit(Ard, Tgl, Ttmp)
Terbit1 = Terbi - Taf
End Function

Function Magrib1(Ard, Bt, Tgl, Ttmp, Markaz)
Taf = Tafaut1(Tgl, Bt, Markaz)
Magri = Magrib(Ard, Tgl, Ttmp)
Magrib1 = Magri - Taf
End Function

Function Dluha1(Ard, Bt, Tgl, Markaz)
Taf = Tafaut1(Tgl, Bt, Markaz)
Dluh = Dluha(Ard, Tgl)
Dluha1 = Dluh - Taf
End Function

Function Dluhur1(Tgl, Bt, Markaz)
Dluhur1 = 12 - Tafaut1(Tgl, Bt, Markaz)
End Function

Function Ashar1(Ard, Bt, Tgl, Markaz)
Taf = Tafaut1(Tgl, Bt, Markaz)
Asar = Ashar(Ard, Tgl)
Ashar1 = Asar - Taf
End Function


Function Isya1(Ard, Bt, Tgl, Markaz)
Taf = Tafaut1(Tgl, Bt, Markaz)
Isy = Isya(Ard, Tgl)
Isya1 = Isy - Taf
End Function

Function Range360(x As Double) As Double
Range360 = x - 360 * Int(x / 360)
End Function

Function AzimutQiblat(LintangT As Double, BujurT As Double) As Double
Dim AQ As Double
AQ = Application.Degrees(Application.Atan2((Cos(Application.Radians(LintangT)) _
* Tan(Application.Radians(21 + 25 / 60)) - Sin(Application.Radians(LintangT)) _
* Cos(Application.Radians((39 + 50 / 60) - BujurT))), _
Sin(Application.Radians((39 + 50 / 60) - BujurT))))
AzimutQiblat = Range360(AQ)
End Function

Function Drj(x)
Jam = Format(Fix(x), "0#")
Mnt = Format(Fix(Abs((x - Fix(x)) * 60)), "0#")
Dtk = Format((Abs(((x - Fix(x)) * 60) - Fix((x - Fix(x)) * 60))) * 60, "0#")
If Jam = 0 And x < 0 Then
Jam = "-00"
Else
Jam = Jam
End If
Drj = Jam & Chr(176) & " " & Mnt & Chr(39) & " " & Dtk & Chr(34)
End Function

Function Hpasar(tgl As Date)
Dim Myweek, Mypasar, Har, Pas
Har = tgl Mod 7
Pas = tgl Mod 5
Myweek = Array("Sabtu", "Ahad", "Senin", "Selasa", "Rabu", "Kamis", "Jum'at")
Mypasar = Array("Kliwon", "Legi", "Pahing", "Pon", "Wage")
Hpasar = Myweek(Har) & " " & Mypasar(Pas)
End Function

Function Terbilang(n As Long) As String 'max 2.147.483.647
Dim satuan As Variant
On Error GoTo terbilang_error
satuan = Array("", "Satu", "Dua", "Tiga", "Empat", "Lima", "Enam", "Tujuh", "Delapan", "Sembilan", "Sepuluh", "Sebelas")
Select Case n
Case 0 To 11
Terbilang = " " + satuan(Fix(n))
Case 12 To 19
Terbilang = Terbilang(n Mod 10) + " Belas"
Case 20 To 99
Terbilang = Terbilang(Fix(n / 10)) + " Puluh" + Terbilang(n Mod 10)
Case 100 To 199
Terbilang = " Seratus" + Terbilang(n - 100)
Case 200 To 999
Terbilang = Terbilang(Fix(n / 100)) + " Ratus" + Terbilang(n Mod 100)
Case 1000 To 1999
Terbilang = " Seribu" + Terbilang(n - 1000)
Case 2000 To 999999
Terbilang = Terbilang(Fix(n / 1000)) + " Ribu" + Terbilang(n Mod 1000)
Case 1000000 To 999999999
Terbilang = Terbilang(Fix(n / 1000000)) + " Juta" + Terbilang(n Mod 1000000)
Case Else
Terbilang = Terbilang(Fix(n / 1000000000)) + " Milyar" + Terbilang(n Mod 1000000000)
End Select
Exit Function
terbilang_error:
MsgBox Err.Description, vbCritical, "^_^ Terbilang Error"
End Function


Catatan:
Kombinasi karakter spasi dan underscore ( _) digunakan untuk pindah ke baris bawah tanpa memutus susunan rumus tersebut.
Anda juga masih harus menulis rumus-rumus yang ada di buku Hisab Falak, karena antara satu dengan yang lainnya masih berkesinambungan.