I use this code and sometimes happends, that the getfirstitem is not able to find my rich-text field in the document! Sometimes it finds it (usually when i save the document manually, close it and open again)!
As I have read the manual, this function should work also for rich-text items!
Is there something wrong in my code?
Sub Click(Source As Button)
Dim ws As New NotesUIWorkspace
Dim uidoc As NotesUIDocument
Dim doc As NotesDocument
Dim rtitem As NotesRichTextItem
Set uidoc=ws.CurrentDocument
Set doc=uidoc.Document
uidoc.EditMode=True
REM The doc has to be saved first, so afterwards the getfirstelement function is working
Call doc.Save(False,False)
REM find a rich-text
Set rtitem=doc.GetFirstItem("rtitem")
Call rtitem.AppendText("This text has been added to the rich-text field")
Call doc.Save(False,False)
Subject: RE: Getfirstitem is not able to find rich-text filed
If you create the rich text field on the back end (doc) then NotesUIDocument.Refresh can pull it into the front-end document (uidoc). However, if you filled in a richtext field in the open document, Save is the only way to get it to the back-end.
Subject: RE: Getfirstitem is not able to find rich-text filed
If you create the rich text field on the back end (doc) then NotesUIDocument.Refresh> can pull it into the front-end document (uidoc).
Come on, put up or shut up. What do you say to $50 U.S.? Obviously since you’re making the positive assertion, it would be up to you to prove it – it’s logically impossible to demonstrate a negative.
However, if you filled in a richtext field in the open document, Save is the only way to get it to the back-end.
You haven’t proven it can’t be done in any other way – you just showed one way that doesn’t work. Since I’m the one saying that there is a way to do it with Refresh, it’s up to me to prove this one, which I will do if you bet me another $50.
Andre Guirard
IBM Lotus Software
Notes Client Development Team
Lotusphere Presenter
IBM Redbook Contributor and Author of a Whole Lot of Technical Articles
Who has written Extensively on Rich Text Programmability
Subject: RE: Getfirstitem is not able to find rich-text filed
“Come on, put up or shut up. What do you say to $50 U.S.? Obviously since you’re making the positive assertion, it would be up to you to prove it – it’s logically impossible to demonstrate a negative.”
It’s been awhile since I’ve been on this forum regularly. I didn’t realize Lotus personnel were now trolling for spare change here. I thought the board was people who posted solutions if they had them. Guess I was wrong.
If you have an alternative to my code that will work, post it if you want. Don’t post it if you don’t want.
Subject: RE: Getfirstitem is not able to find rich-text filed
I couldn’t post the solution for using Refresh to move back end changes to the front end, since there is no such solution.
I did post the solution for reading a rich text item from the open document, in this thread. I said, “you can also get to it without saving by using the argument to NotesUIDocument.Refresh.” And I encouraged reading the documentation of this method, which you apparently didn’t do, judging by your response. So I decided to motivate you to try harder.
I find it irritating when people won’t read the docs they’re pointed to and don’t bother to search, insisting that they know better than everyone else. Especially when they’re busy misinforming others.
My suggestions: when in doubt, check it out. And if someone contradicts you, check it out even if in no doubt. Otherwise, you become impervious to new information. Things change, and nobody’s memory is perfect.
Subject: RE: Getfirstitem is not able to find rich-text filed
Uf, Uf … When I have created this thread, I was in Belgium. During the weekend I have moved to Slovakia and just revised my thread (hoping to find an answer to my question). Actually I found and this is the most important for me ;o) So, thx to both of you - hope you are still both alive ;o)