Cuec
asked on
why do I loose my rich text formatting
I wrote lotus script which merges two documents but the results loose its formatting....does anyone know how I can preserve this.
the script is:
Sub Click(Source As Button)
Dim ws As New NotesUIWorkspace
Dim uidoc As NotesUIDocument
Dim session As New NotesSession
Dim db As NotesDatabase
Dim view As NotesView
Dim selected As NotesDocument
Dim selectedit As NotesItem
Dim subject As NotesItem
Dim newdoc As NotesDocument
Dim newit As NotesRichTextItem
Dim temp As NotesDocument
Dim tempit As NotesRichTextItem
Dim section As NotesRichTextItem
Dim content As NotesRichTextItem
Dim mystyle As NotesRichTextStyle
Dim reptypekey As NotesItem
Set db = session.CurrentDatabase
'find template for report
'1) find the type of report
Set view = db.GetView("Report_Merge")
Set selected = view.GetFirstDocument
Set subject = selected.GetFirstItem("Rep Type")
reporttype = "Template for "+subject.text
'2) find the template document for this type of report
Set view = db.GetView("Report_Temp")
Set selected = view.GetFirstDocument
found = False
Do While Not found
Set subject = selected.GetFirstItem("Sub jectDis")
If subject.text = reporttype Then
found = True
Else
Set selected = view.GetNextDocument(selec ted)
End If
Loop
Set section = selected.GetFirstItem("Rep Type")
subj = section.text
'record the section names in the order as they appear in the report template
Set section = selected.GetFirstItem("tem p1")
section1 = section.text
Set section = selected.GetFirstItem("tem p2")
section2 = section.text
Set reptypekey = selected.GetFirstItem("Rep Type_1")
reptypekey1 = reptypekey.text
'get the corresponding contents for each section
Set view = db.GetView("Report_Merge")
If Not section1 = "" Then
'1) find the chunk of documents that belongs to section 1
Set selected = view.GetFirstDocument
Set temp = view.GetFirstDocument
found = False
Do While Not found
Set section = selected.GetFirstItem("Rep Section")
If section.text = section1 Then
found = True
Else
Set selected = view.GetNextDocument(selec ted)
Set temp = view.GetNextDocument(temp)
End If
Loop
'2) get all contents that belongs to the documents in this chunk
Set tempit = temp.GetFirstItem("temp")
finished = False
Do While Not (selected Is Nothing) And Not finished
Set section = selected.GetFirstItem("Rep Section")
If section.text = section1 Then
Set content = selected.GetFirstItem("Con tent")
Call tempit.AppendText(content. text)
Call tempit.AddNewLine(2)
Set selected = view.GetNextDocument(selec ted)
Else
finished = True
End If
Loop
content1 = tempit.text
End If
'get the corresponding contents for each section
Set view = db.GetView("Report_Merge")
If Not section2 = "" Then
'1) find the chunk of documents that belongs to section 1
Set selected = view.GetFirstDocument
Set temp = view.GetFirstDocument
found = False
Do While Not found
Set section = selected.GetFirstItem("Rep Section")
If section.text = section2 Then
found = True
Else
Set selected = view.GetNextDocument(selec ted)
Set temp = view.GetNextDocument(temp)
End If
Loop
'2) get all contents that belongs to the documents in this chunk
Set tempit = temp.GetFirstItem("temp")
finished = False
Do While Not (selected Is Nothing) And Not finished
Set section = selected.GetFirstItem("Rep Section")
If section.text = section2 Then
Set content = selected.GetFirstItem("Con tent")
Call tempit.AppendText(content. text)
Call tempit.AddNewLine(2)
Set selected = view.GetNextDocument(selec ted)
Else
finished = True
End If
Loop
content2 = tempit.text
End If
Set mystyle = session.CreateRichTextStyl e
Set newdoc = view.GetFirstDocument
Set newit = newdoc.GetFirstItem("temp2 ")
If Not (section1="" And content1="") Then
Call newit.AppendText(section1)
Call newit.AddNewLine(2)
Call newit.AppendText(content1)
Call newit.AddNewLine(1)
Call newit.AppendText("-------- ---------- ---------- ---------- ---------- ---------- ---------- ")
Call newit.AddNewLine(2)
End If
If Not (section2="" And content2="") Then
Call newit.AppendText(section2)
Call newit.AddNewLine(2)
Call newit.AppendText(content2)
Call newit.AddNewLine(1)
Call newit.AppendText("-------- ---------- ---------- ---------- ---------- ---------- ---------- ")
Call newit.AddNewLine(2)
End If
Set uidoc = ws.ComposeDocument("",""," Report Skeleton")
Call uidoc.FieldSetText("Subjec t", subj)
Call uidoc.FieldSetText("Report Content", newit.text)
Call uidoc.FieldSetText("RepTyp e", subj)
Call uidoc.FieldSetText("DocTyp e_1", reptypekey1)
End Sub
the script is:
Sub Click(Source As Button)
Dim ws As New NotesUIWorkspace
Dim uidoc As NotesUIDocument
Dim session As New NotesSession
Dim db As NotesDatabase
Dim view As NotesView
Dim selected As NotesDocument
Dim selectedit As NotesItem
Dim subject As NotesItem
Dim newdoc As NotesDocument
Dim newit As NotesRichTextItem
Dim temp As NotesDocument
Dim tempit As NotesRichTextItem
Dim section As NotesRichTextItem
Dim content As NotesRichTextItem
Dim mystyle As NotesRichTextStyle
Dim reptypekey As NotesItem
Set db = session.CurrentDatabase
'find template for report
'1) find the type of report
Set view = db.GetView("Report_Merge")
Set selected = view.GetFirstDocument
Set subject = selected.GetFirstItem("Rep
reporttype = "Template for "+subject.text
'2) find the template document for this type of report
Set view = db.GetView("Report_Temp")
Set selected = view.GetFirstDocument
found = False
Do While Not found
Set subject = selected.GetFirstItem("Sub
If subject.text = reporttype Then
found = True
Else
Set selected = view.GetNextDocument(selec
End If
Loop
Set section = selected.GetFirstItem("Rep
subj = section.text
'record the section names in the order as they appear in the report template
Set section = selected.GetFirstItem("tem
section1 = section.text
Set section = selected.GetFirstItem("tem
section2 = section.text
Set reptypekey = selected.GetFirstItem("Rep
reptypekey1 = reptypekey.text
'get the corresponding contents for each section
Set view = db.GetView("Report_Merge")
If Not section1 = "" Then
'1) find the chunk of documents that belongs to section 1
Set selected = view.GetFirstDocument
Set temp = view.GetFirstDocument
found = False
Do While Not found
Set section = selected.GetFirstItem("Rep
If section.text = section1 Then
found = True
Else
Set selected = view.GetNextDocument(selec
Set temp = view.GetNextDocument(temp)
End If
Loop
'2) get all contents that belongs to the documents in this chunk
Set tempit = temp.GetFirstItem("temp")
finished = False
Do While Not (selected Is Nothing) And Not finished
Set section = selected.GetFirstItem("Rep
If section.text = section1 Then
Set content = selected.GetFirstItem("Con
Call tempit.AppendText(content.
Call tempit.AddNewLine(2)
Set selected = view.GetNextDocument(selec
Else
finished = True
End If
Loop
content1 = tempit.text
End If
'get the corresponding contents for each section
Set view = db.GetView("Report_Merge")
If Not section2 = "" Then
'1) find the chunk of documents that belongs to section 1
Set selected = view.GetFirstDocument
Set temp = view.GetFirstDocument
found = False
Do While Not found
Set section = selected.GetFirstItem("Rep
If section.text = section2 Then
found = True
Else
Set selected = view.GetNextDocument(selec
Set temp = view.GetNextDocument(temp)
End If
Loop
'2) get all contents that belongs to the documents in this chunk
Set tempit = temp.GetFirstItem("temp")
finished = False
Do While Not (selected Is Nothing) And Not finished
Set section = selected.GetFirstItem("Rep
If section.text = section2 Then
Set content = selected.GetFirstItem("Con
Call tempit.AppendText(content.
Call tempit.AddNewLine(2)
Set selected = view.GetNextDocument(selec
Else
finished = True
End If
Loop
content2 = tempit.text
End If
Set mystyle = session.CreateRichTextStyl
Set newdoc = view.GetFirstDocument
Set newit = newdoc.GetFirstItem("temp2
If Not (section1="" And content1="") Then
Call newit.AppendText(section1)
Call newit.AddNewLine(2)
Call newit.AppendText(content1)
Call newit.AddNewLine(1)
Call newit.AppendText("--------
Call newit.AddNewLine(2)
End If
If Not (section2="" And content2="") Then
Call newit.AppendText(section2)
Call newit.AddNewLine(2)
Call newit.AppendText(content2)
Call newit.AddNewLine(1)
Call newit.AppendText("--------
Call newit.AddNewLine(2)
End If
Set uidoc = ws.ComposeDocument("","","
Call uidoc.FieldSetText("Subjec
Call uidoc.FieldSetText("Report
Call uidoc.FieldSetText("RepTyp
Call uidoc.FieldSetText("DocTyp
End Sub
Avoid using the NotesRichtext.Text property. That's where the formatting get stripped from the content.
ASKER
what should I use instead?
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
How are you doing, Cuec?