星期日, 10月 21, 2018

[Notes]判斷Richtext欄位是否空白

Function IsRTFNull(rtfield As String) As Integer
On Error GoTo Errhandle
Dim uidoc As NotesUIDocument
Dim workspace As New NotesUIWorkspace
Set uidoc = workspace.CurrentDocument
Call uidoc.GotoField( rtfield )
Call uidoc.SelectAll
'The next line will generate a 4407 error message if the Rich Text Field is null
Call uidoc.DeselectAll
'Return the cursor the the field that had focus before this function ran. If the currentfield variable is null
'(because a button or hotspot had focus, then the cursor will actually wind up getting left in the rich text field.
IsRTFNull = False
Exit Function

Errhandle:
Select Case Err
Case 4407
'the DeselectAll line generated an error message, indicating that the rich text field does not contain anything
If currentfield <> "" Then
Call uidoc.GotoField(currentfield)
End If

IsRTFNull = True
Exit Function
Case Else
'For any other error, force the same error to cause LotusScript to do the error handling
Error Err
End Select

End Function

沒有留言: