?
Solved

why do I  loose my rich text formatting

Posted on 2003-03-31
6
Medium Priority
?
232 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 3
6 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

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

For beginners of Lotus Notes user this is important to know about the types of files and their location supported by IBM Notes. Mostly users are unaware about how many file types are created and what their usages are. This Article is fully dedicated…
Notes Document Link used by IBM Notes is a link file which aids in the sharing of links to documents in email and webpages. The posts describe the importance and steps to create a Lotus Notes NDL file in brief.
Do you want to know how to make a graph with Microsoft Access? First, create a query with the data for the chart. Then make a blank form and add a chart control. This video also shows how to change what data is displayed on the graph as well as form…
In this video, Percona Solution Engineer Rick Golba discuss how (and why) you implement high availability in a database environment. To discuss how Percona Consulting can help with your design and architecture needs for your database and infrastr…

765 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