• Add a button on the view: Copt pwd to clipboard

    By Stephan H. Wissel 2 decades ago

    To add convenience to the pwd repository I added a button on the view level to copy the pwd to the clipboard. In essence its the same as on the form, it only opens/closes the document first. This is my button code:

    Sub Click(Source As Button)

    Const DIALOG_TITLE = &quot;Set your new password&quot;<br/>
    'View Version, get the selected document from the view<br/>
    <br/>
    Dim Session As New NotesSession<br/>
    Dim Workspace As New NotesUIWorkspace<br/>
    Dim UIDoc As NotesUIDocument<br/>
    Dim Doc As NotesDocument<br/>
    Dim PWD_Item As NotesItem<br/>
    Dim USR_Item As NotesItem<br/>
    Dim tmpItem As NotesItem<br/>
    Dim CurrentUser As NotesName<br/>
    Dim flag As Integer<br/>
    Dim openFlag As Boolean<br/>
    openFlag = False<br/>
    <br/>
    Set CurrentUser = New NotesName(Session.EffectiveUserName)<br/>
    'Check if we get the UIDoc<br/>
    Set UIDoc = Workspace.CurrentDocument<br/>
    'if failed we try open<br/>
    If UIDoc Is Nothing Then<br/>
        Set UIDoc = Workspace.EditDocument(False)<br/>
        openFlag = True <br/>
    End If<br/>
    If UIDoc Is Nothing Then<br/>
        'Didn't work either<br/>
        Msgbox &quot;Sorry no document&quot;<br/>
        Exit Sub<br/>
    End If<br/>
    Set Doc = UIDoc.Document<br/>
    <br/>
    <br/>
    Call SetClipboardText(Doc.Password(0))<br/>
    Print &quot;Password copied to clipboard.&quot;<br/>
    If openFlag Then<br/>
        UIDoc.Close<br/>
    End If<br/>
    

    End Sub