Hi, I am looking for a way to tranfer a rich text field from one document to another while keeping the text formatting and hyperlinks. The transfer is to take place in script.
Subject: Tranfer Rich Text from one doc to the other via script
ExampleCopies an item to a specified document.
Defined in
NotesItem
Syntax
Set notesItem = notesItem.CopyItemToDocument( document, newName$ )
Parameters
document
NotesDocument. The document on which to create the item. If you specify Nothing, this method generates an error.
newName$
String. The name of the new item.
Return value
notesItem
NotesItem. The new item in the specified document, with the specified name.
Language cross-reference
copyItemToDocument method in Java Item class
Example
See Also
CopyAllItems method (in NotesDocument)
Copying an item in LotusScript classes
CopyItem method (in NotesDocument)
NotesDocument class
Subject: RE: Tranfer Rich Text from one doc to the other via script
already tried the copy item and copyitemtodocument, but seems that text formatting and hyperlinks inserted in the text are lost, I suspect because they inherit from the NotesItem class that does not handle formatting.
Subject: RE: Tranfer Rich Text from one doc to the other via script
These methods do copy formatting and URL links and tables and…
Perhaps you should post your code.
Subject: RE: Tranfer Rich Text from one doc to the other via script
ok, here is the setup, the user has a document opens, click on a button, the codes fetches the right document and fills fields on the document the user has opened… All other fields are text, but the field (on the document we are fetching the information from) “SectionOutilTravFr” is rich text, and so is the field we are putting the information into “intro_Outil”
…
Call uidocCourant.FieldSetText(“intro_SecteurQui”, doc.SectionTextFr(0))
Call uidocCourant.FieldSetText(“intro_PromesseService”, doc.SectionPromServFr(0))
Call uidocCourant.FieldSetText(“intro_Pol_Proc_1”, doc.SectionPoliltiqueFr_1(0))
Call uidocCourant.FieldSetText(“intro_Pol_Proc_1_UNID”, doc.SectionPoliltiqueFr_1_UNID(0))
Call uidocCourant.FieldSetText(“intro_Pol_Proc_2”, doc.SectionPoliltiqueFr_2(0))
Call uidocCourant.FieldSetText(“intro_Pol_Proc_2_UNID”, doc.SectionPoliltiqueFr_2_UNID(0))
Call uidocCourant.FieldSetText(“intro_Pol_Proc_3”, doc.SectionPoliltiqueFr_3(0))
Call uidocCourant.FieldSetText(“intro_Pol_Proc_3_UNID”, doc.SectionPoliltiqueFr_3_UNID(0))
Call uidocCourant.Save
Set rtItem = doc.GetFirstItem(“SectionOutilTravFr”)
Set rtItem2 = New NotesRichTextItem(uidocCourant.Document, “intro_Outil”)
’ Call rtItem2.AppendRTItem(rtItem)
’ Call uidocCourant.FieldSetText(“intro_Outil”, doc.SectionOutilTravFr(0))
’ Call rtItem.CopyItemToDocument(uidocCourant.Document, “intro_Outil”)
uidocCourant.Document.intro_Outil = doc.SectionOutilTravFr
…
Basically in comment is a few things I have tried, not all of them, but a few…
I would appreciate any help on this problem, or on the other one I am having, thanks a lot
Subject: RE: Tranfer Rich Text from one doc to the other via script
I was unable to find where in your code you are using CopyItemToDocument or CopyAllItems.
What I do see is you assigning the rich text field using the doc.fieldname = otherdoc.fieldname format. Since “rich text value” is not a valid LotusScript datatype, this assignment can only copy the text of the field. What is that value on the right side of the =; what is its datatype?
I think you need to read this: Update rich text tip.
Also, this statement:
Set rtItem2 = New NotesRichTextItem(uidocCourant.Document, “intro_Outil”)
is incorrect. You must not create a new rich text item, when the document already contains a rich text item with that name. Instead, use GetFirstItem to retrieve it. But first you must use uidoc.Refresh(True) so that the back-end rich text is up to date.
Call rtItem2.AppendRTItem(rtItem)
is a good way to copy the rich text to your document. I’m not sure whether you might get an extra blank line or other badness. In that case you could Remove the old rich-text item and use CopyItemToDocument.
Subject: RE: Tranfer Rich Text from one doc to the other via script
Actually André, I am having a small problem with the code… Basically I am working within a frame so prevent the opening of lots of window by the user and keep a ‘web’ look.
The problem is that the code I use closes the uidoc, and when I navigate elsewhere, I am not in my frame anymore, and when I set the target frame, I get the error “Target Frame is ancestor of the Script Object”, and I cannot set the EditDocument Method to not return the uidoc, I need it to set some more fields after, because it I set them before, they loose their values when I set the rich text… Here is my code…
…
Call uidocCourant.Save
If doc.HasItem("SectionOutilTravFr") Then
Set rtItem = doc.GetFirstItem("SectionOutilTravFr")
Call doc2.RemoveItem("intro_Outil")
Set rtItem2 = New NotesRichTextItem(uidocCourant.Document, "intro_Outil")
Set rtItem2 = doc2.GetFirstItem("intro_Outil")
Call rtItem2.AppendRTItem(rtItem)
Call doc2.ComputeWithForm(True, False)
doc2.SaveOptions = "0"
Call uidocCourant.Close(True)
' Call ws.OpenFrameSet("Main")
' Call ws.SetTargetFrame("Main")
Set uidocNew = ws.EditDocument(True, doc2 , , , , )
Delete uidocCourant
uidocNew.Document.RemoveItem("SaveOptions")
Set uidocCourant = uidocNew
End If
Call uidocCourant.FieldSetText("intro_SecteurQui", doc.SectionTextFr(0))
Call uidocCourant.FieldSetText("intro_PromesseService", doc.SectionPromServFr(0))
Call uidocCourant.FieldSetText("intro_Pol_Proc_1", doc.SectionPoliltiqueFr_1(0))
Call uidocCourant.FieldSetText("intro_Pol_Proc_1_UNID", doc.SectionPoliltiqueFr_1_UNID(0))
Call uidocCourant.FieldSetText("intro_Pol_Proc_2", doc.SectionPoliltiqueFr_2(0))
Call uidocCourant.FieldSetText("intro_Pol_Proc_2_UNID", doc.SectionPoliltiqueFr_2_UNID(0))
Call uidocCourant.FieldSetText("intro_Pol_Proc_3", doc.SectionPoliltiqueFr_3(0))
Call uidocCourant.FieldSetText("intro_Pol_Proc_3_UNID", doc.SectionPoliltiqueFr_3_UNID(0))
…
Subject: RE: Tranfer Rich Text from one doc to the other via script
Ahhhh, good good, got it to work with the help of your other document and the CopyItemToDocument…
Thanks a lot André, don’t suppose you have a solution for my other problem with the folder?