這個函數可以被用來確認使用者是否在 Rich Text 欄位加入了什麼。
在一個套表中,若是含有必須填入值的 Rich Text 欄位,這是非常有用的函數。
從你確認生效的例行程式中去呼叫這個函數,來檢驗你的 RTF 是不是空的。
在一個套表中,若是含有必須填入值的 Rich Text 欄位,這是非常有用的函數。
從你確認生效的例行程式中去呼叫這個函數,來檢驗你的 RTF 是不是空的。
Function IsRTFNull(rtfield As String) As Integer
'This function tests a Rich Text field to see whether or not it
is null. It returns TRUE if 'the field is null, and returns
FALSE if the field is not null. It works even if the rich
'text field contains a file attachment, doclink, or OLE
object but does not contain any 'text.
On Error Goto Errhandle
Dim workspace As New NotesUIWorkspace
Dim uidoc As NotesUIDocument
Set uidoc = workspace.CurrentDocument
Call uidoc.ExpandAllSections
'This is only needed if your field is in a section that may be closed when this executes
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
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
留言