VBA/Excel/Access/Word/Access/Database Protect — различия между версиями

Материал из VB Эксперт
Перейти к: навигация, поиск
м (1 версия)
 
м (1 версия)
 
(нет различий)

Текущая версия на 12:47, 26 мая 2010

Protect from mark

 
Sub ProtectItFromMark()
    Dim db As Database
    Dim Doc As Document
    Set db = CurrentDb()
    Set Doc = db.Containers("Forms").Documents("frmPassword")
    Doc.UserName = "M"
    Doc.Permissions = dbSecFullAccess And Not dbSecDelete
End Sub



Show all permissions

 
Sub ShowPerms()
 
    Dim objContainer As Container
    Dim objDoc As Document
    For Each objContainer In CurrentDb.Containers
        Debug.Print objContainer.Name
        For Each objDoc In objContainer.Documents
            Debug.Print "Document: " & objDoc.Name;
            objDoc.UserName = "Admin"
            Debug.Print "Perms: " & objDoc.AllPermissions
        Next
    Next
    Debug.Print "Done"
 
End Sub



Show delete permission

 
Sub ShowNoDelPerms()
    Dim objContainer As Container
    Dim objDoc As Document
    For Each objContainer In CurrentDb.Containers
        Debug.Print objContainer.Name
        For Each objDoc In objContainer.Documents
            If (objDoc.AllPermissions And dbSecDelete) = dbSecDelete Then
                Debug.Print "Can Delete Document: " & objDoc.Name;
                objDoc.UserName = "Admin"
                Debug.Print "Perms: " & objDoc.AllPermissions
            Else
                Debug.Print "Cannot Delete Document: " & objDoc.Name;
                objDoc.UserName = "Admin"
                Debug.Print "Perms: " & objDoc.AllPermissions
            End If
        Next
    Next
End Sub