Link to home
Start Free TrialLog in
Avatar of kautz
kautz

asked on

Adding a second table to a richtextitem in Lotusscript

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.
Avatar of Sjef Bosman
Sjef Bosman
Flag of France image

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...
Avatar of kautz
kautz

ASKER

Great idea.  Hadn't thought of that.  I'll give it a try and let you know.  May be tomorrow.
Avatar of kautz

ASKER

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.
R6? Do you have the script, we might be able to test it here, on R7.
Avatar of kautz

ASKER

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
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] )
Avatar of kautz

ASKER

No.  I'll try that this weekend if I get a chance.
ASKER CERTIFIED SOLUTION
Avatar of Sjef Bosman
Sjef Bosman
Flag of France image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of kautz

ASKER

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.
YANF...

Yust Another Notes Feature :)