I would like to know the method to dynamically add rows to a table in Lotus Notes.
Subject: NotesRichTextTable.AddRow ![]()
Subject: RE: NotesRichTextTable.AddRow ![]()
Is there a way to alter tables in the UI? It’s pretty useless (IMHO) editing something that’s not open. I want to make an invoice screen and add rows as I need them, though it seems to be a tall order in Notes…
Subject: RE: NotesRichTextTable.AddRow ![]()
If you want to do anything in the open UI, you need to use @Commands. Start by understanding that what is open in the rich text editor is not the same as the rich text field – there is almost an application/file relationship between the two. LotusScript can only operate on the “file” using the NotesRichTextX classes.
Subject: You can do this with LotusScript
You have to add the row via LotusScript, then save the document and reopen it using the editdocument method.
The code below is from our Notes Domino 6 Application Development Update course (see http://www.tlcc.com/r6) See the blue code…
Sub Click(Source As Button)
Dim uiw As New NotesUIWorkspace
Dim uidoc As NotesUIDocument
Set uidoc = uiw.CurrentDocument
Dim doc As NotesDocument
Set doc = uidoc.Document
Dim Body As NotesRichTextItem
Set body = doc.GetFirstItem("Body")
If body Is Nothing Then
Msgbox "Click on the Reset the demo action to create the table first."
End If
Dim rows As Integer, rownumber As Integer, numrowstoadd As Integer
Dim strrownumber As String, strrowstoadd As String
Dim rtnav As NotesRichTextNavigator
Set rtnav = body.CreateNavigator
Dim rttable As NotesRichTextTable
Set rttable = rtnav.GetFirstElement(RTELEM_TYPE_TABLE)
If rttable Is Nothing Then
Msgbox "No table created - use the Reset the demo action first."
Else
rows=rttable.RowCount
strrowstoadd = Inputbox("Enter the number of rows to add.")
If Isnumeric( strrowstoadd ) Then
numrowstoAdd = Cint(strrowstoAdd)
If numrowstoAdd <= 0 Then
Msgbox "Enter a number greater than zero."
Exit Sub
End If
Else
Msgbox ("Enter a integer number only.")
Exit Sub
End If
strrownumber = Inputbox("Enter the number corresponding to the row to start adding at, no greater than " & rows & ".")
If Isnumeric( strrownumber ) Then
rownumber = Cint(strrownumber)
If rownumber < 0 Or rownumber > rows Then
Msgbox ("You entered too high a number or a number less than zero, try again.")
Exit Sub
End If
Else
Msgbox ("Enter a integer number only.")
Exit Sub
End If
Call rttable.AddRow(numrowstoadd, rownumber)
End If
doc.save True, True
uidoc.Close
Call uiw.EditDocument(False,doc)
End Sub
Howard