Examples: InsertText method

This script, for an action, inserts the user's name into the current field whenever the action is clicked.

Sub Click(Source As Button)
  Dim session As New NotesSession
  Dim workspace As New NotesUIWorkspace
  Dim uidoc As NotesUIDocument
  Set uidoc = workspace.CurrentDocument
  Call uidoc.InsertText( session.CommonUserName )
End Sub

This script, for a button, inserts the user's name into FieldOne whenever the button is clicked. You cannot insert into the "current" field with a button because the focus is on the button.

Sub Click(Source As Button)
  Dim session As New NotesSession
  Dim workspace As New NotesUIWorkspace
  Dim uidoc As NotesUIDocument
  Set uidoc = workspace.CurrentDocument
  Call uidoc.GotoField( "FieldOne" )
  Call uidoc.InsertText( session.CommonUserName )
End Sub