Hello Everyone, I need some help!I’ve these code and it’s an error (Object Variable Not Set) in the line that have the <<< >>>.
Thanks
Function IsRTFNull(strFieldName As String) As Integer
Dim WS As New NotesUIWorkspace
Dim CurrentUIDoc As NotesUIDocument
Dim CampoRT As NotesRichTextItem
Dim rtnav As NotesRichTextNavigator
Dim ArchivoCompleto As Variant
Dim rtitem As Variant
Set CurrentUIDoc = WS.CurrentDocument
rtCount = 0
IsRTFNull = False
Set CampoRT = CurrentUIDoc.Document.GetFirstItem (strFieldName)
<<<<<<<<If (rtitem.Type = RICHTEXT) Then>>>>>>>>>
Set rtnav = CampoRT.CreateNavigator
If rtCount = 0 Then rtCount = GetCount(RTELEM_TYPE_TEXTRUN)
If rtCount = 0 Then rtCount = GetCount(RTELEM_TYPE_TEXTPARAGRAPH)
If rtCount = 0 Then rtCount = GetCount(RTELEM_TYPE_FILEATTACHMENT)
If rtCount = 0 Then rtCount = GetCount(RTELEM_TYPE_DOCLINK)
If rtCount = 0 Then rtCount = GetCount(RTELEM_TYPE_OLE)
If rtCount = 0 Then rtCount = GetCount(RTELEM_TYPE_SECTION)
If rtCount = 0 Then rtCount = GetCount(RTELEM_TYPE_TABLE)
If rtCount = 0 Then rtCount = GetCount(RTELEM_TYPE_TABLECELL)
End If
If rtCount = 0 Then IsRTFNull = True
Sorry, I put it a code that was wrong.This is the one.
Thanks again!!
Function IsRTFNull(strFieldName As String) As Integer
Dim WS As New NotesUIWorkspace
Dim CurrentUIDoc As NotesUIDocument
Dim CampoRT As NotesRichTextItem
Dim rtnav As NotesRichTextNavigator
Set CurrentUIDoc = WS.CurrentDocument
'Dim rtitem As Variant
rtCount = 0
IsRTFNull = False
Set CampoRT = CurrentUIDoc.Document.GetFirstItem (strFieldName)
<<<<<<<If (CampoRT.Type = RICHTEXT) Then>>>>>>>
Set rtnav = CampoRT.CreateNavigator
If rtCount = 0 Then rtCount = GetCount(RTELEM_TYPE_TEXTRUN)
If rtCount = 0 Then rtCount = GetCount(RTELEM_TYPE_TEXTPARAGRAPH)
If rtCount = 0 Then rtCount = GetCount(RTELEM_TYPE_FILEATTACHMENT)
If rtCount = 0 Then rtCount = GetCount(RTELEM_TYPE_DOCLINK)
If rtCount = 0 Then rtCount = GetCount(RTELEM_TYPE_OLE)
If rtCount = 0 Then rtCount = GetCount(RTELEM_TYPE_SECTION)
If rtCount = 0 Then rtCount = GetCount(RTELEM_TYPE_TABLE)
If rtCount = 0 Then rtCount = GetCount(RTELEM_TYPE_TABLECELL)
End If
If rtCount = 0 Then IsRTFNull = True
Most likely your CurrentUIDoc.Document does not contain the strFieldName as a NotesItem. The
Set CampoRT = CurrentUIDoc.Document.GetFirstItem (strFieldName)
must be returning nothing.
Use the debugger to step it through one line at a time to verify. If the NotesItem does not yet exist, as in a new document, you will either have to move the code to a different event (PostSave or other), or performe a ComputeWithForm, or explicitly create the NotesRichTextItem.