;

Rabu, 23 Oktober 2013

Memaksa pengguna untuk mengaktifkan Macro Security


  •  Buat Modul terlebih dahulu
            Insert → Module


Copy coding berikut

Public bIsClosing As Boolean
Dim wsSheet As Worksheet


Sub HideAll()
Application.ScreenUpdating = False
For Each wsSheet In ThisWorkbook.Worksheets
    If wsSheet.CodeName = "Sheet2" Then
       wsSheet.Visible = xlSheetVisible
    Else
       wsSheet.Visible = xlSheetVeryHidden
    End If
Next wsSheet
Application.ScreenUpdating = True
End Sub

Sub ShowAll()
bIsClosing = False
For Each wsSheet In ThisWorkbook.Worksheets
    If wsSheet.CodeName <> "Sheet2" Then
       wsSheet.Visible = xlSheetVisible
    End If
Next wsSheet
Sheet2.Visible = xlSheetVeryHidden
End Sub

  • Pada This Workbook Copykan Coding berikut
Private Sub Workbook_BeforeClose(Cancel As Boolean)
bIsClosing = True
End Sub

Private Sub Workbook_BeforeSave(ByVal SaveAsUI As Boolean, Cancel As Boolean)
If Cancel = True Or bIsClosing = False Then Exit Sub
Run "HideAll"
End Sub

Private Sub Workbook_Deactivate()
If bIsClosing = False Then Exit Sub
Run "HideAll"
End Sub

Private Sub Workbook_Open()
Run "ShowAll"
End Sub

Tidak ada komentar:

Posting Komentar