Examples: GetSelectedText method

  1. This form action appends all currently selected text in a document to a file.
    Sub Click(Source As Button)
      Dim workspace As New NotesUIWorkspace
      Dim uidoc As NotesUIDocument
      Set uidoc = workspace.CurrentDocument
      texxt$ = uidoc.GetSelectedText()
      pathname$ = "c:\Selected.txt"
      fileNum% = Freefile()
      Open pathname$ For Append As fileNum%
      Print #fileNum%, texxt$
      Close #fileNum%
    End Sub
  2. This form action reduces the value of a field to the currently selected text within the field.
    Sub Click(Source As Button)
      Dim workspace As New NotesUIWorkspace
      Dim uidoc As NotesUIDocument
      Dim text As String
      Dim fieldName As String
      fieldName = "Subject"
      Set uidoc = workspace.CurrentDocument
      text = uidoc.GetSelectedText(fieldName)
      If text <> "" Then
        If Not uidoc.EditMode Then uidoc.EditMode = True
        Call uidoc.FieldSetText("Subject", text)
      End If
    End Sub