Converting from notesitem to notesrichtextitem

Hi all,

I am trying to do up a document when i met up with this problem:

Error message: “Type Mismatch”

My code is:

Dim doc As NotesDocument

Dim rtitem As NotesRichTextItem

'…set value of doc…

Set rtitem = doc.GetFirstItem( “Body” )

This section of code is what i had found in the help. I did a Print Typename(…) on the doc.GetFirstItem(“Body”) and rtitem,

and the reply were NOTESRICHTEXTITEM and NOTESITEM. Is there anything i can do to make the conversion?

Thanx.

Regards,

hengshi

Subject: Converting from notesitem to notesrichtextitem

According to the so-called documentation, doc.GetFirstItem can be used to set either a NotesItem or a NotesRichTextItem. In practice, I’ve found that it sometimes (but not always) results in a type mistmatch when you try to set a NotesRichTextItem. I have not figured out why it works in some cases, but not in others. Anyway, since you are encountering the same problem, have you tried the following:

Dim item As NotesItem

Dim rt_item As NotesRichTextItem	

Set item = doc.GetFirstItem("rtfield")

'Test to make sure item is a rich text field

If item.Type = 1 Then

	Set rt_item = item

End If

Subject: RE: Converting from notesitem to notesrichtextitem

Hey RLB,

Thanx a lot dude, the problem is solved.

hengshi