Converting Private Agents to Shared Agents Progammatically

I posted this code as a reply yesterday, but I thought I would make a new thread so more people could see it. I’d like opinions and suggestions on the code below. The code is designed to convert a private agent to a shared agent and remove it from the Actions menu. If anyone knows of anything I may have left out or has any suggestions, please feel free to respond.

Thanks,

MJ

Sub Initialize

Dim s As New NotesSession

Dim db As NotesDatabase

Dim nc As NotesNoteCollection

Dim doc As NotesDocument

Dim flagsbefore As String

Dim flagsafter As String

Dim aflagsbefore As String

Dim aflagsafter As String

Dim retval As Variant

Dim nid As String

Dim nextnid As String

Set db = s.CurrentDatabase

Set nc = db.CreateNoteCollection(False)

nc.SelectAgents = True

Call nc.BuildCollection

nid = nc.GetFirstNoteId

For i = 1 To nc.Count

nextid = nc.GetNextNoteId(nid)

Set doc = db.GetDocumentByID(nid)

If Not(doc Is Nothing) Then

’ if $Flags contains a V and $AssistFlags contains a P, then it is a private agent

flagsbefore=doc.GetItemValue(“$Flags”)(0)

aflagsbefore=doc.GetItemValue(“$AssistFlags”)(0)

If Instr(flagsbefore,“V”)<>0 Then

flagsafter=Replace(flagsbefore,“V”,“”)

aflagsafter=Replace(aflagsbefore,“P”,“”)

'Adding 456789 to the end of $Flags removes it from the menu for versions 4-9

Call doc.ReplaceItemValue(“$Flags”,flagsafter + “456789”)

Call doc.ReplaceItemValue(“$AssistFlags”,aflagsafter)

Call doc.Save(True,False)

End If

End If

nid = nextid

Next

End Sub