Solved

Adding a second table to a richtextitem in Lotusscript

Posted on 2006-07-13
10
1,478 Views
Last Modified: 2013-12-18
I'm trying out those newer (to me anyway) rich text classes they added in R6.  In a server agent I am creating a new document, adding a rich text item to it, adding some text, a table, some more text and another table.  So far I have it working fine up to the second table.  If I don't try to add the second table, I get a nice document with text and a table all formatted as I want it.

I try to add the second table with the following code:
      Call reportbody.AppendTable(row, 11)

row holds the value 49.
reportbody is my NotesRichTextItem on my new document.

The error I get when this line of code tries to execute is:
                Illegal column width - check Left and Right margins

The first table is defined as Call reportbody.AppendTable(6, 11) and the 11 column width is just fine.  I haven't done anything with style properties so anything having to do with margins are all at whatever the defaults are.
0
Comment
Question by:kautz
[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
  • 5
  • 5
10 Comments
 
LVL 46

Expert Comment

by:Sjef Bosman
ID: 17103914
I never used them on R6, and what I used made my Notes client crash :)

Just as a bypass: can you create the second table in a new richtext item, and then add the whole item to the first one, using
    Call notesRichTextItem.AppendRTItem( notesRichTextItem2 )

Two cents...
0
 

Author Comment

by:kautz
ID: 17105258
Great idea.  Hadn't thought of that.  I'll give it a try and let you know.  May be tomorrow.
0
 

Author Comment

by:kautz
ID: 17107237
Got the same error this way.  I did go to a regular mail memo and just for kicks created 49 row, 11 column basic tables and they created just fine.  But I would expect this.  A 6 row, 11 column table takes the same width as a 49 row, 11 column table.  Don't know why Notes doesn't like this in the Lotusscript.
0
Industry Leaders: 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!

 
LVL 46

Expert Comment

by:Sjef Bosman
ID: 17107447
R6? Do you have the script, we might be able to test it here, on R7.
0
 

Author Comment

by:kautz
ID: 17109175
This is my "playground" agent where I am trying to prove out some things on these new features.  Before I start the second table you'll see that I assign a value to ROW.  I have narrowed it down.  A value up to 21 in ROW will result in the script working.  A value of 22 or higher results in the error mentioned above.

The code's definately messy, but it's just for these tests before I use it in production.

Sub Initialize
      Dim report As NotesDocument
      Dim reporttitle As String
      Dim reportbody As NotesRichTextItem
      
      Dim db As New notesdatabase("","")
      Dim doc As notesdocument
      Dim view As NotesView
      
       'Open the database    
      Call db.open("","")
      
      'Set up report variables
      Set report = New NotesDocument(db)
      report.Form = "ReportForm"
      Set reportbody = New NotesRichTextItem(report,"reportbody")
      
      Dim addit As Double
      Dim tb As String
      Dim lf As String
      Dim row As Integer
      Dim col As Integer
      Dim bol As Boolean
      
      tb = Chr(9)
      lf = Chr(10)
      
      'Heading
      reporttitle = "My Test Report" & lf & " for week ending XXXXX"
      
      'Task Summary By Type
      Call reportbody.AppendText(lf & "Summary By Type" & lf & "--------------------------------" & lf & lf)
      
      Call reportbody.AppendText(tb & tb &"Tasks"& tb & tb & tb & "Help Tix"& tb & tb & tb &"Ongoing" & tb & tb & tb  &"Tot Hrs" & lf)
      Call reportbody.AppendText(tb & tb &"Num"& tb & "Hours"& tb &"Whrs"& tb & "Num"&_
      tb & "Hours"& tb &"Whrs"& tb & "Num"& tb & "Hours"& tb &"Whrs"& tb & lf)
      
      'Summary by Type in Table Form
      Call reportbody.AppendTable(6, 11)
      'Populate table
      Dim rtnav As NotesRichTextNavigator
      Set rtnav = reportbody.CreateNavigator
      Call rtnav.FindFirstElement(RTELEM_TYPE_TABLECELL)
      'Table Headers
      Call rtnav.FindNthElement(RTELEM_TYPE_TABLECELL,3)
      Call reportbody.BeginInsert(rtnav)
      Call reportbody.appendtext("Tasks")
      Call reportbody.EndInsert
      Call rtnav.FindNthElement(RTELEM_TYPE_TABLECELL,6)
      Call reportbody.BeginInsert(rtnav)
      Call reportbody.appendtext("HelpTix")
      Call reportbody.EndInsert
      Call rtnav.FindNthElement(RTELEM_TYPE_TABLECELL,9)
      Call reportbody.BeginInsert(rtnav)
      Call reportbody.appendtext("Ongoing")
      Call reportbody.EndInsert
      Call rtnav.FindNthElement(RTELEM_TYPE_TABLECELL,11)
      Call reportbody.BeginInsert(rtnav)
      Call reportbody.appendtext("Tot"& lf & "Hrs")
      Call reportbody.EndInsert
      Call rtnav.FindNthElement(RTELEM_TYPE_TABLECELL,13)
      Call reportbody.BeginInsert(rtnav)
      Call reportbody.appendtext("Count")
      Call reportbody.EndInsert
      Call rtnav.FindNthElement(RTELEM_TYPE_TABLECELL,14)
      Call reportbody.BeginInsert(rtnav)
      Call reportbody.appendtext("Cum" & lf & "Hrs")
      Call reportbody.EndInsert
      Call rtnav.FindNthElement(RTELEM_TYPE_TABLECELL,15)
      Call reportbody.BeginInsert(rtnav)
      Call reportbody.appendtext("Wks" & lf & "Hrs")
      Call reportbody.EndInsert
      Call rtnav.FindNthElement(RTELEM_TYPE_TABLECELL,16)
      Call reportbody.BeginInsert(rtnav)
      Call reportbody.appendtext("Count")
      Call reportbody.EndInsert
      Call rtnav.FindNthElement(RTELEM_TYPE_TABLECELL,17)
      Call reportbody.BeginInsert(rtnav)
      Call reportbody.appendtext("Cum" & lf & "Hrs")
      Call reportbody.EndInsert
      Call rtnav.FindNthElement(RTELEM_TYPE_TABLECELL,18)
      Call reportbody.BeginInsert(rtnav)
      Call reportbody.appendtext("Wks" & lf & "Hrs")
      Call reportbody.EndInsert      
      Call rtnav.FindNthElement(RTELEM_TYPE_TABLECELL,19)
      Call reportbody.BeginInsert(rtnav)
      Call reportbody.appendtext("Count")
      Call reportbody.EndInsert
      Call rtnav.FindNthElement(RTELEM_TYPE_TABLECELL,20)
      Call reportbody.BeginInsert(rtnav)
      Call reportbody.appendtext("Cum" & lf & "Hrs")
      Call reportbody.EndInsert
      Call rtnav.FindNthElement(RTELEM_TYPE_TABLECELL,21)
      Call reportbody.BeginInsert(rtnav)
      Call reportbody.appendtext("Wks" & lf & "Hrs")
      Call reportbody.EndInsert
      Call rtnav.FindNthElement(RTELEM_TYPE_TABLECELL,22)
      Call reportbody.BeginInsert(rtnav)
      Call reportbody.appendtext("Total" & lf & "Hours")
      Call reportbody.EndInsert
      
      
      'Summary By Customer
      Call reportbody.AppendText(lf & "Summary By Customer" & lf & "--------------------------------" & lf & lf)
      
      Call reportbody.AppendText(tb & tb &"Tasks"& tb & tb & tb & "Help Tix"& tb & tb & tb &"Ongoing" & tb & tb & tb  &"Tot Hrs" & lf)
      Call reportbody.AppendText(tb & tb &"Num"& tb & "Hours"& tb &"Whrs"& tb & "Num"&_
      tb & "Hours"& tb &"Whrs"& tb & "Num"& tb & "Hours"& tb &"Whrs"& tb & lf)
      
      
      Print "NO ERROR YET 001"            
      'Task Summary by Customer in Table Form
      
      Dim rt2 As NotesRichTextItem
      Set rt2 = New NotesRichTextItem(report,"reportbody2")
      
      row = 22
      
      
      Print "NO ERROR YET 002    row = "& row
      Call rt2.AppendTable(row, 11)
      
      'Create new navigator
      Dim rtnav2 As NotesRichTextNavigator
      Set rtnav2 = rt2.CreateNavigator
      Call rtnav2.FindFirstElement(RTELEM_TYPE_TABLECELL)
      
      'Populate table
      Print "NO ERROR YET 003"      
      'Table Headers   RTELEM_TYPE_TABLE
      bol = rtnav2.FindNextElement(RTELEM_TYPE_TABLECELL)
      If bol Then
            Print "We FOUND the next table cell!!!!"
      Else
            Print "Huh? Wheres the table cells dude?"
      End If            
      Print "NO ERROR YET 004"      
      Call rtnav2.FindNextElement(RTELEM_TYPE_TABLECELL)
      Call rtnav2.FindNextElement(RTELEM_TYPE_TABLECELL)
      Call rt2.BeginInsert(rtnav2)
      Call rt2.appendtext("Tasks")
      Call rt2.EndInsert
      Call rtnav2.FindNextElement(RTELEM_TYPE_TABLECELL)
      Call rtnav2.FindNextElement(RTELEM_TYPE_TABLECELL)
      Call rtnav2.FindNextElement(RTELEM_TYPE_TABLECELL)
      Call rt2.BeginInsert(rtnav2)
      Call rt2.appendtext("HelpTix")
      Call rt2.EndInsert
      Call rtnav2.FindNextElement(RTELEM_TYPE_TABLECELL)
      Call rtnav2.FindNextElement(RTELEM_TYPE_TABLECELL)
      Call rtnav2.FindNextElement(RTELEM_TYPE_TABLECELL)
      Call rt2.BeginInsert(rtnav2)
      Call rt2.appendtext("Ongoing")
      Call rt2.EndInsert
      Call rtnav2.FindNextElement(RTELEM_TYPE_TABLECELL)
      Call rtnav2.FindNextElement(RTELEM_TYPE_TABLECELL)
      Call rt2.BeginInsert(rtnav2)
      Call rt2.appendtext("Tot"& lf & "Hrs")
      Call rt2.EndInsert
      Call rtnav2.FindNextElement(RTELEM_TYPE_TABLECELL)
      Call rtnav2.FindNextElement(RTELEM_TYPE_TABLECELL)
      Call rt2.BeginInsert(rtnav2)
      Call rt2.appendtext("Count")
      Call rt2.EndInsert
      Call rtnav2.FindNextElement(RTELEM_TYPE_TABLECELL)
      Call rt2.BeginInsert(rtnav2)
      Call rt2.appendtext("Cum" & lf & "Hrs")
      Call rt2.EndInsert
      Call rtnav2.FindNextElement(RTELEM_TYPE_TABLECELL)
      Call rt2.BeginInsert(rtnav2)
      Call rt2.appendtext("Wks" & lf & "Hrs")
      Call rt2.EndInsert
      Call rtnav2.FindNextElement(RTELEM_TYPE_TABLECELL)
      Call rt2.BeginInsert(rtnav2)
      Call rt2.appendtext("Count")
      Call rt2.EndInsert
      Call rtnav2.FindNextElement(RTELEM_TYPE_TABLECELL)
      Call rt2.BeginInsert(rtnav2)
      Call rt2.appendtext("Cum" & lf & "Hrs")
      Call rt2.EndInsert
      Call rtnav2.FindNextElement(RTELEM_TYPE_TABLECELL)
      Call rt2.BeginInsert(rtnav2)
      Call rt2.appendtext("Wks" & lf & "Hrs")
      Call rt2.EndInsert      
      Call rtnav2.FindNextElement(RTELEM_TYPE_TABLECELL)
      Call rt2.BeginInsert(rtnav2)
      Call rt2.appendtext("Count")
      Call rt2.EndInsert
      Call rtnav2.FindNextElement(RTELEM_TYPE_TABLECELL)
      Call rt2.BeginInsert(rtnav2)
      Call rt2.appendtext("Cum" & lf & "Hrs")
      Call rt2.EndInsert
      Call rtnav2.FindNextElement(RTELEM_TYPE_TABLECELL)
      Call rt2.BeginInsert(rtnav2)
      Call rt2.appendtext("Wks" & lf & "Hrs")
      Call rt2.EndInsert
      Call rtnav2.FindNextElement(RTELEM_TYPE_TABLECELL)
      Call rt2.BeginInsert(rtnav2)
      Call rt2.appendtext("Total" & lf & "Hours")
      Call rt2.EndInsert      
      Print "NO ERROR YET 101"            
      
      Call reportbody.AppendRTItem( rt2 )
      
      'Close out
      Call reportbody.AppendText(lf + "***End Of Report***")
      report.reporttitle = reporttitle
      report.reporttype = "Report"
      Call report.save(False, True)
      
End Sub
0
 
LVL 46

Expert Comment

by:Sjef Bosman
ID: 17111075
Same error in R7.

Did you try with the fifth parameter? Read the Designer Help database:

Syntax
    Call notesRichTextItem.AppendTable( rows%, columns% [, labels]  [, leftMargin&]  [, rtpsStyleArray] )
0
 

Author Comment

by:kautz
ID: 17112953
No.  I'll try that this weekend if I get a chance.
0
 
LVL 46

Accepted Solution

by:
Sjef Bosman earned 500 total points
ID: 17114586
   Dim rts(10) As NotesRichTextParagraphStyle
    For col=0 To 10
        Set rts(col)= ns.CreateRichTextParagraphStyle
        rts(col).LeftMargin= 0
        rts(col).RightMargin= 1
    Next
    ' Stop
    row = 22
   
   
    Print "NO ERROR YET 002    row = "& row
    Call rt2.AppendTable(row, 11, , , rts)

It compiles and runs past the AppendTable. What the results would have been I don't know, I stopped the debugger :)
0
 

Author Comment

by:kautz
ID: 17122047
Using the NotesRichTextParagraphStyle looks like it will do the trick.  Very odd that Lotus Notes can format 11 columns OK without it only when the row size is below 22, but you gotta play the hand you are dealt.

Appreciate you running the test script on R7, hope to have that installed here by 1Q 2007.
0
 
LVL 46

Expert Comment

by:Sjef Bosman
ID: 17122573
YANF...

Yust Another Notes Feature :)
0

Featured Post

On Demand Webinar - Networking for the Cloud Era

This webinar discusses:
-Common barriers companies experience when moving to the cloud
-How SD-WAN changes the way we look at networks
-Best practices customers should employ moving forward with cloud migration
-What happens behind the scenes of SteelConnect’s one-click button

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Only send email if contains "abcd" 3 151
Switching from Lotus Notes to Outlook 4 60
IBM Domino web server 5 72
problem with deleted user 14 38
IBM Notes offer Encryption feature using which the user can secure its NSF emails or entire database easily. In this section we will discuss about the process to Encrypt Incoming and Outgoing Mails in depth.
This article covers general Notes 8.5 troubleshooting information including recreating the Notes\Data folder.
A short tutorial showing how to set up an email signature in Outlook on the Web (previously known as OWA). For free email signatures designs, visit https://www.mail-signatures.com/articles/signature-templates/?sts=6651 If you want to manage em…

733 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