Want to protect your cyber security and still get fast solutions? Ask a secure question today.Go Premium

x
?
Solved

why do I  loose my rich text formatting

Posted on 2003-03-31
6
Medium Priority
?
233 Views
Last Modified: 2013-12-18
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("RepType")
      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("SubjectDis")
            If subject.text = reporttype Then
                  found = True
            Else
                  Set selected = view.GetNextDocument(selected)
            End If
      Loop
      Set section = selected.GetFirstItem("RepType")
      subj = section.text
      'record the section names in the order as they appear in the report template
      Set section = selected.GetFirstItem("temp1")
      section1 = section.text
      Set section = selected.GetFirstItem("temp2")
      section2 = section.text
      Set reptypekey = selected.GetFirstItem("RepType_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("RepSection")
                  If section.text = section1 Then
                        found = True
                  Else
                        Set selected = view.GetNextDocument(selected)
                        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("RepSection")
                  If section.text = section1 Then
                        Set content = selected.GetFirstItem("Content")
                        Call tempit.AppendText(content.text)
                        Call tempit.AddNewLine(2)
                        Set selected = view.GetNextDocument(selected)
                  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("RepSection")
                  If section.text = section2 Then
                        found = True
                  Else
                        Set selected = view.GetNextDocument(selected)
                        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("RepSection")
                  If section.text = section2 Then
                        Set content = selected.GetFirstItem("Content")
                        Call tempit.AppendText(content.text)
                        Call tempit.AddNewLine(2)
                        Set selected = view.GetNextDocument(selected)
                  Else
                        finished = True
                  End If
            Loop
            content2 = tempit.text
      End If
      
      Set mystyle = session.CreateRichTextStyle
      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("Subject", subj)
      Call uidoc.FieldSetText("ReportContent", newit.text)
      Call uidoc.FieldSetText("RepType", subj)
      Call uidoc.FieldSetText("DocType_1", reptypekey1)
End Sub
0
Comment
Question by:Cuec
  • 3
4 Comments
 
LVL 13

Expert Comment

by:CRAK
ID: 8237688
Avoid using the NotesRichtext.Text property. That's where the formatting get stripped from the content.
0
 

Author Comment

by:Cuec
ID: 8237787
what should I use instead?
0
 
LVL 13

Accepted Solution

by:
CRAK earned 500 total points
ID: 8237945
I'd create a document in the backend, fill out all fields and then open it in edit mode.
Try to fill a new RT field, top to bottom, using:

Call NotesRichTextItem.AppendRTItem( NotesRichTextItem2 ),

AppendStyle and Appendtext just as you do and

Set NotesItem = NotesItem.CopyItemToDocument( NotesDocument, NewName$ )
0
 
LVL 13

Expert Comment

by:CRAK
ID: 8546556
How are you doing, Cuec?
0

Featured Post

Concerto Cloud for Software Providers & ISVs

Can Concerto Cloud Services help you focus on evolving your application offerings, while delivering the best cloud experience to your customers? From DevOps to revenue models and customer support, the answer is yes!

Learn how Concerto can help you.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

This is an old article, please see an updated version of this article, located here: http://www.experts-exchange.com/articles/23619/Notes-8-5x-Windows-7-Notes-info-and-tips.html
You’ve got a lotus Domino web server, and you have been told that “leverage browser caching” is a must do. This means that we have to tell the browser everywhere in the web to use cache. In other words, we set (and send) an expiration date in the HT…
this video summaries big data hadoop online training demo (http://onlineitguru.com/big-data-hadoop-online-training-placement.html) , and covers basics in big data hadoop .
When cloud platforms entered the scene, users and companies jumped on board to take advantage of the many benefits, like the ability to work and connect with company information from various locations. What many didn't foresee was the increased risk…
Suggested Courses
Course of the Month12 days, 10 hours left to enroll

579 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question