Solved

Adding a second table to a richtextitem in Lotusscript

Posted on 2006-07-13
10
1,472 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
  • 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
Free Tool: IP Lookup

Get more info about an IP address or domain name, such as organization, abuse contacts and geolocation.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

 
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

Free Tool: Subnet Calculator

The subnet calculator helps you design networks by taking an IP address and network mask and returning information such as network, broadcast address, and host range.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

Problem "Can you help me recover my changes?  I double-clicked the attachment, made changes, and then hit Save before closing it.  But when I try to re-open it, my changes are missing!"    Solution This solution opens the Outlook Secure Temp Fold…
Lack of Storage capacity is a common problem that exists in every field of life. Here we are taking the case of Lotus Notes Emails, as we all know that we are totally depend on e-communication i.e. Emails. This article is fully dedicated to resolvin…
This video shows how to quickly and easily add an email signature for all users on Exchange 2016. The resulting signature is applied on a server level by Exchange Online. The email signature template has been downloaded from: www.mail-signatures…
In an interesting question (https://www.experts-exchange.com/questions/29008360/) here at Experts Exchange, a member asked how to split a single image into multiple images. The primary usage for this is to place many photographs on a flatbed scanner…

861 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