Function FreeDatabaseDesign(db As NotesDatabase, inheritfromtemplate As Boolean, prohibitreplacerefresh As Boolean, propagateprohibition As boolean) As Boolean ' CONSTANTS Const CHAR_FLAG_1 = "P" Const CHAR_FLAG_2 = "r" ' VARIABLES Dim notecol As NotesNoteCollection Dim doc As NotesDocument Dim noteid As String Dim id As String Dim x As Integer Dim tempval As String Dim cansave As Boolean On Error GoTo ErrorHandler ' CODE ' Specify True to collect everything by default. This will be Designs and Documents Set notecol = db.CreateNoteCollection(true) ' Remove Documents from Collection. We only want Design Elements notecol.SelectDocuments = False Call notecol.BuildCollection noteid = notecol.GetFirstNoteId ' Loop through each Design Element For x = 1 To notecol.Count id = notecol.GetNextNoteId(noteid) Set doc = db.GetDocumentByID(noteid) If Not( doc Is Nothing ) Then cansave = False ' There are 3 Properties that this code will check for: ' - Inherit from Design Template - ($Class = Template Name) ' - Prohibit Design Refresh or Replace to modify - ($Flags = P) ' - Propagate this prohibition of design change - ($Flags = r) If (prohibitreplacerefresh = True) Or (propagateprohibition = True) Then If doc.hasItem("$Flags") Then If (prohibitreplacerefresh = True) And (InStr(doc.~$Flags(0),CHAR_FLAG_1)) Then ' Remove the Character P from Field tempval = Replace(doc.~$Flags(0), CHAR_FLAG_1, "") Call doc.Replaceitemvalue("$Flags", tempval) cansave = true End If If (propagateprohibition = True) And (InStr(doc.~$Flags(0),CHAR_FLAG_2)) Then ' Remove the Character P from Field tempval = Replace(doc.~$Flags(0), CHAR_FLAG_2, "") Call doc.Replaceitemvalue("$Flags", tempval) cansave = True End If End If End If If inheritfromtemplate = True Then If doc.hasItem("$Class") Then If doc.~$Class(0) <> "" Then Call doc.Replaceitemvalue("$Class", "") cansave = True End If End If End If ' Check if we have to save Design Element If cansave Then Call doc.Save(true, false) End If End If noteid = id Next ' Return True that the Code ran Successfully FreeDatabaseDesign = true Done: Exit Function ErrorHandler: ' Print Error and Return False Print "FreeDatabaseDesign Function Error: " + Error$ + " - Line: " + CStr(Erl) FreeDatabaseDesign = false Resume Done End Function