(Options)
Option Public
Option Declare
Use "ConstantsNotesAPI"
Public Function IsPrivateFolder(v As Variant) As Boolean
Dim vdoc As NotesDocument
Dim item As NotesItem
IsPrivateFolder = False
Set vdoc = v.Parent.GetDocumentByUNID(v.UniversalID)
If Not vdoc Is Nothing Then
If vdoc.HasItem("$Flags") Then
Set item = vdoc.GetFirstItem("$Flags")
If Instr(item.Values(0), "V") > 0 Then IsPrivateFolder = True
End If
End If
End Function
Public Function DeletePrivateFolder(db As NotesDatabase, vname$) As Boolean
Dim p$
Dim hDB&
Dim retNoteID&
Dim result%
Dim doc As NotesDocument
On Error Goto err_handler
DeletePrivateFolder = False
' To open a Domino database on a server, use this function to create
' the full path specification, and pass this specification as input to NSFDbOpen
' or NSFDbOpenExtended.
p = String(1024, " ")
OSPathNetConstruct 0, db.Server, db.FilePath, p$
' This function takes a pathname to an existing Domino database or database
' template (whether on a Lotus Domino Server or a local database), opens the
' database, and returns a handle to it. All subsequent access to the database is
' carried out via this handle. Use NSFDbClose to close the database file handle
' and deallocate the memory associated with it.
NSFDbOpen p$, hDB
' Given the name and NOTE_CLASS_xxx of a private design note (form, view,
' folder, helpindex, macro, field, or replication formula ), this function returns the note ID.
' Uses the View or Folder name passed to it - vname.
result = NIFFindPrivateDesignNote(hDB, vname, NOTE_CLASS_VIEW, retNoteID)
'If result is anything other than 0, the Private Design Note could not be found
If Not result = 0 Then
Print GetAPIError(result)
Exit Function
End If
' Get the Private View or Folder by its NoteID
Set doc = db.GetDocumentByID(Hex$(retNoteID))
Call doc.Remove(True)
DeletePrivateFolder = True
Exit Function
err_handler:
Print "Error " & Cstr(Err) & " at line " & Cstr(Erl) & ": " & Error$ + "."
Exit Function
Resume Next
End Function
Public Function GetPrivateFolder(vname$, valias$) As NotesView
Dim ses As New NotesSession
Dim db As NotesDatabase
Dim p$
Dim hDB&
Dim retNoteID&
Dim result%
Dim doc
Dim new_folder_flag As Boolean
On Error Goto err_handler
Set GetPrivateFolder = Nothing
new_folder_flag = False
Set db = ses.CurrentDatabase
' To open a Domino database on a server, use this function to create
' the full path specification, and pass this specification as input to NSFDbOpen
' or NSFDbOpenExtended.
p = String(1024, " ")
OSPathNetConstruct 0, db.Server, db.FilePath, p$
NSFDbOpen p$, hDB
result = NIFFindPrivateDesignNote(hDB, vname, NOTE_CLASS_VIEW, retNoteID)
'If result is anything other than 0, the Private Design Note could not be found
If result = 0 Then
Set doc = db.GetDocumentByID(Hex$(retNoteID))
If doc Is Nothing Then new_folder_flag = True
Set GetPrivateFolder = db.GetView(vname)
Else
Print GetAPIError(result)
new_folder_flag = True
End If
Exit Function
err_handler:
Print "Error " & Cstr(Err) & " at line " & Cstr(Erl) & ": " & Error$ + "."
Exit Function
Resume Next
err_api_error:
Print "API Error " & Cstr(result) & ": " & GetAPIError(result) + "."
Exit Function
Resume Next
End Function
Public Function GetAPIError(errorCode%) As String
' this function translates Notes API error codes into their
' corresponding error strings
Dim errorString As String*256
Dim returnErrorString$
Dim resultStringLength&
Dim errorCodeTranslated%
' mask off the top 2 bits of the errorCode that was returned; this is
' what the ERR macro in the API does
errorCodeTranslated = (errorCode And ERR_MASK)
' get the error code translation using the OSLoadString API function
resultStringLength = OSLoadString(0, errorCodeTranslated, errorString, Len(errorString) - 1)
' strip off the null-termination on the string before you return it
If Instr(errorString, Chr(0)) > 0 Then
returnErrorString = Left$(errorString, Instr(errorString, Chr(0)) - 1)
Else
returnErrorString = errorString
End If
GetAPIError = returnErrorString
End Function