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.
I try to add the second table with the following code:
Call reportbody.AppendTable(row
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.
ASKER
Great idea. Hadn't thought of that. I'll give it a try and let you know. May be tomorrow.
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.
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(RTE LEM_TYPE_T ABLECELL)
'Table Headers
Call rtnav.FindNthElement(RTELE M_TYPE_TAB LECELL,3)
Call reportbody.BeginInsert(rtn av)
Call reportbody.appendtext("Tas ks")
Call reportbody.EndInsert
Call rtnav.FindNthElement(RTELE M_TYPE_TAB LECELL,6)
Call reportbody.BeginInsert(rtn av)
Call reportbody.appendtext("Hel pTix")
Call reportbody.EndInsert
Call rtnav.FindNthElement(RTELE M_TYPE_TAB LECELL,9)
Call reportbody.BeginInsert(rtn av)
Call reportbody.appendtext("Ong oing")
Call reportbody.EndInsert
Call rtnav.FindNthElement(RTELE M_TYPE_TAB LECELL,11)
Call reportbody.BeginInsert(rtn av)
Call reportbody.appendtext("Tot "& lf & "Hrs")
Call reportbody.EndInsert
Call rtnav.FindNthElement(RTELE M_TYPE_TAB LECELL,13)
Call reportbody.BeginInsert(rtn av)
Call reportbody.appendtext("Cou nt")
Call reportbody.EndInsert
Call rtnav.FindNthElement(RTELE M_TYPE_TAB LECELL,14)
Call reportbody.BeginInsert(rtn av)
Call reportbody.appendtext("Cum " & lf & "Hrs")
Call reportbody.EndInsert
Call rtnav.FindNthElement(RTELE M_TYPE_TAB LECELL,15)
Call reportbody.BeginInsert(rtn av)
Call reportbody.appendtext("Wks " & lf & "Hrs")
Call reportbody.EndInsert
Call rtnav.FindNthElement(RTELE M_TYPE_TAB LECELL,16)
Call reportbody.BeginInsert(rtn av)
Call reportbody.appendtext("Cou nt")
Call reportbody.EndInsert
Call rtnav.FindNthElement(RTELE M_TYPE_TAB LECELL,17)
Call reportbody.BeginInsert(rtn av)
Call reportbody.appendtext("Cum " & lf & "Hrs")
Call reportbody.EndInsert
Call rtnav.FindNthElement(RTELE M_TYPE_TAB LECELL,18)
Call reportbody.BeginInsert(rtn av)
Call reportbody.appendtext("Wks " & lf & "Hrs")
Call reportbody.EndInsert
Call rtnav.FindNthElement(RTELE M_TYPE_TAB LECELL,19)
Call reportbody.BeginInsert(rtn av)
Call reportbody.appendtext("Cou nt")
Call reportbody.EndInsert
Call rtnav.FindNthElement(RTELE M_TYPE_TAB LECELL,20)
Call reportbody.BeginInsert(rtn av)
Call reportbody.appendtext("Cum " & lf & "Hrs")
Call reportbody.EndInsert
Call rtnav.FindNthElement(RTELE M_TYPE_TAB LECELL,21)
Call reportbody.BeginInsert(rtn av)
Call reportbody.appendtext("Wks " & lf & "Hrs")
Call reportbody.EndInsert
Call rtnav.FindNthElement(RTELE M_TYPE_TAB LECELL,22)
Call reportbody.BeginInsert(rtn av)
Call reportbody.appendtext("Tot al" & 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," reportbody 2")
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(RT ELEM_TYPE_ TABLECELL)
'Populate table
Print "NO ERROR YET 003"
'Table Headers RTELEM_TYPE_TABLE
bol = rtnav2.FindNextElement(RTE LEM_TYPE_T ABLECELL)
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(RTE LEM_TYPE_T ABLECELL)
Call rtnav2.FindNextElement(RTE LEM_TYPE_T ABLECELL)
Call rt2.BeginInsert(rtnav2)
Call rt2.appendtext("Tasks")
Call rt2.EndInsert
Call rtnav2.FindNextElement(RTE LEM_TYPE_T ABLECELL)
Call rtnav2.FindNextElement(RTE LEM_TYPE_T ABLECELL)
Call rtnav2.FindNextElement(RTE LEM_TYPE_T ABLECELL)
Call rt2.BeginInsert(rtnav2)
Call rt2.appendtext("HelpTix")
Call rt2.EndInsert
Call rtnav2.FindNextElement(RTE LEM_TYPE_T ABLECELL)
Call rtnav2.FindNextElement(RTE LEM_TYPE_T ABLECELL)
Call rtnav2.FindNextElement(RTE LEM_TYPE_T ABLECELL)
Call rt2.BeginInsert(rtnav2)
Call rt2.appendtext("Ongoing")
Call rt2.EndInsert
Call rtnav2.FindNextElement(RTE LEM_TYPE_T ABLECELL)
Call rtnav2.FindNextElement(RTE LEM_TYPE_T ABLECELL)
Call rt2.BeginInsert(rtnav2)
Call rt2.appendtext("Tot"& lf & "Hrs")
Call rt2.EndInsert
Call rtnav2.FindNextElement(RTE LEM_TYPE_T ABLECELL)
Call rtnav2.FindNextElement(RTE LEM_TYPE_T ABLECELL)
Call rt2.BeginInsert(rtnav2)
Call rt2.appendtext("Count")
Call rt2.EndInsert
Call rtnav2.FindNextElement(RTE LEM_TYPE_T ABLECELL)
Call rt2.BeginInsert(rtnav2)
Call rt2.appendtext("Cum" & lf & "Hrs")
Call rt2.EndInsert
Call rtnav2.FindNextElement(RTE LEM_TYPE_T ABLECELL)
Call rt2.BeginInsert(rtnav2)
Call rt2.appendtext("Wks" & lf & "Hrs")
Call rt2.EndInsert
Call rtnav2.FindNextElement(RTE LEM_TYPE_T ABLECELL)
Call rt2.BeginInsert(rtnav2)
Call rt2.appendtext("Count")
Call rt2.EndInsert
Call rtnav2.FindNextElement(RTE LEM_TYPE_T ABLECELL)
Call rt2.BeginInsert(rtnav2)
Call rt2.appendtext("Cum" & lf & "Hrs")
Call rt2.EndInsert
Call rtnav2.FindNextElement(RTE LEM_TYPE_T ABLECELL)
Call rt2.BeginInsert(rtnav2)
Call rt2.appendtext("Wks" & lf & "Hrs")
Call rt2.EndInsert
Call rtnav2.FindNextElement(RTE LEM_TYPE_T ABLECELL)
Call rt2.BeginInsert(rtnav2)
Call rt2.appendtext("Count")
Call rt2.EndInsert
Call rtnav2.FindNextElement(RTE LEM_TYPE_T ABLECELL)
Call rt2.BeginInsert(rtnav2)
Call rt2.appendtext("Cum" & lf & "Hrs")
Call rt2.EndInsert
Call rtnav2.FindNextElement(RTE LEM_TYPE_T ABLECELL)
Call rt2.BeginInsert(rtnav2)
Call rt2.appendtext("Wks" & lf & "Hrs")
Call rt2.EndInsert
Call rtnav2.FindNextElement(RTE LEM_TYPE_T ABLECELL)
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
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,"
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 & "-------------------------
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(RTE
'Table Headers
Call rtnav.FindNthElement(RTELE
Call reportbody.BeginInsert(rtn
Call reportbody.appendtext("Tas
Call reportbody.EndInsert
Call rtnav.FindNthElement(RTELE
Call reportbody.BeginInsert(rtn
Call reportbody.appendtext("Hel
Call reportbody.EndInsert
Call rtnav.FindNthElement(RTELE
Call reportbody.BeginInsert(rtn
Call reportbody.appendtext("Ong
Call reportbody.EndInsert
Call rtnav.FindNthElement(RTELE
Call reportbody.BeginInsert(rtn
Call reportbody.appendtext("Tot
Call reportbody.EndInsert
Call rtnav.FindNthElement(RTELE
Call reportbody.BeginInsert(rtn
Call reportbody.appendtext("Cou
Call reportbody.EndInsert
Call rtnav.FindNthElement(RTELE
Call reportbody.BeginInsert(rtn
Call reportbody.appendtext("Cum
Call reportbody.EndInsert
Call rtnav.FindNthElement(RTELE
Call reportbody.BeginInsert(rtn
Call reportbody.appendtext("Wks
Call reportbody.EndInsert
Call rtnav.FindNthElement(RTELE
Call reportbody.BeginInsert(rtn
Call reportbody.appendtext("Cou
Call reportbody.EndInsert
Call rtnav.FindNthElement(RTELE
Call reportbody.BeginInsert(rtn
Call reportbody.appendtext("Cum
Call reportbody.EndInsert
Call rtnav.FindNthElement(RTELE
Call reportbody.BeginInsert(rtn
Call reportbody.appendtext("Wks
Call reportbody.EndInsert
Call rtnav.FindNthElement(RTELE
Call reportbody.BeginInsert(rtn
Call reportbody.appendtext("Cou
Call reportbody.EndInsert
Call rtnav.FindNthElement(RTELE
Call reportbody.BeginInsert(rtn
Call reportbody.appendtext("Cum
Call reportbody.EndInsert
Call rtnav.FindNthElement(RTELE
Call reportbody.BeginInsert(rtn
Call reportbody.appendtext("Wks
Call reportbody.EndInsert
Call rtnav.FindNthElement(RTELE
Call reportbody.BeginInsert(rtn
Call reportbody.appendtext("Tot
Call reportbody.EndInsert
'Summary By Customer
Call reportbody.AppendText(lf & "Summary By Customer" & 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,"
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(RT
'Populate table
Print "NO ERROR YET 003"
'Table Headers RTELEM_TYPE_TABLE
bol = rtnav2.FindNextElement(RTE
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(RTE
Call rtnav2.FindNextElement(RTE
Call rt2.BeginInsert(rtnav2)
Call rt2.appendtext("Tasks")
Call rt2.EndInsert
Call rtnav2.FindNextElement(RTE
Call rtnav2.FindNextElement(RTE
Call rtnav2.FindNextElement(RTE
Call rt2.BeginInsert(rtnav2)
Call rt2.appendtext("HelpTix")
Call rt2.EndInsert
Call rtnav2.FindNextElement(RTE
Call rtnav2.FindNextElement(RTE
Call rtnav2.FindNextElement(RTE
Call rt2.BeginInsert(rtnav2)
Call rt2.appendtext("Ongoing")
Call rt2.EndInsert
Call rtnav2.FindNextElement(RTE
Call rtnav2.FindNextElement(RTE
Call rt2.BeginInsert(rtnav2)
Call rt2.appendtext("Tot"& lf & "Hrs")
Call rt2.EndInsert
Call rtnav2.FindNextElement(RTE
Call rtnav2.FindNextElement(RTE
Call rt2.BeginInsert(rtnav2)
Call rt2.appendtext("Count")
Call rt2.EndInsert
Call rtnav2.FindNextElement(RTE
Call rt2.BeginInsert(rtnav2)
Call rt2.appendtext("Cum" & lf & "Hrs")
Call rt2.EndInsert
Call rtnav2.FindNextElement(RTE
Call rt2.BeginInsert(rtnav2)
Call rt2.appendtext("Wks" & lf & "Hrs")
Call rt2.EndInsert
Call rtnav2.FindNextElement(RTE
Call rt2.BeginInsert(rtnav2)
Call rt2.appendtext("Count")
Call rt2.EndInsert
Call rtnav2.FindNextElement(RTE
Call rt2.BeginInsert(rtnav2)
Call rt2.appendtext("Cum" & lf & "Hrs")
Call rt2.EndInsert
Call rtnav2.FindNextElement(RTE
Call rt2.BeginInsert(rtnav2)
Call rt2.appendtext("Wks" & lf & "Hrs")
Call rt2.EndInsert
Call rtnav2.FindNextElement(RTE
Call rt2.BeginInsert(rtnav2)
Call rt2.appendtext("Count")
Call rt2.EndInsert
Call rtnav2.FindNextElement(RTE
Call rt2.BeginInsert(rtnav2)
Call rt2.appendtext("Cum" & lf & "Hrs")
Call rt2.EndInsert
Call rtnav2.FindNextElement(RTE
Call rt2.BeginInsert(rtnav2)
Call rt2.appendtext("Wks" & lf & "Hrs")
Call rt2.EndInsert
Call rtnav2.FindNextElement(RTE
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.AppendTa ble( rows%, columns% [, labels] [, leftMargin&] [, rtpsStyleArray] )
Did you try with the fifth parameter? Read the Designer Help database:
Syntax
Call notesRichTextItem.AppendTa
ASKER
No. I'll try that this weekend if I get a chance.
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
Using the NotesRichTextParagraphStyl e 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.
Appreciate you running the test script on R7, hope to have that installed here by 1Q 2007.
YANF...
Yust Another Notes Feature :)
Yust Another Notes Feature :)
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.AppendRT
Two cents...