Sub Initialize%REM
Introduction
=========
This AGENT code creates a new document in the current database and creates a 3 row 2 column table in a rich text field called ‘Body’.
Problem is, when the agent is RunOnServer the error “Missing RichTextParagraphStyle object” ocurrs at the line:
Call body.AppendTable(3,2, , ,ParaStyle_Array)
{Call notesRichTextItem.AppendTable( rows%, columns% [, labels] [, leftMargin&] [, rtpsStyleArray] )} - ND6 Help
Note: that to simplify, the two rtpStyles I create are assigned to different varibles (but the same rtpStyle could have been used in both - it errors that way too)
I have also tried providing all arguements - still creates error.
Instructions
=========
-
Copy this code into a new agent called “TestCreateTable”
-
Set it to run on ‘All documents in database’
-
In Domino Designer right click it and select ‘Run’ - it will work fine…
BUT Problem is…
=============
4a. Schedule it and allow it to run, or
4b. Put the following code in an action button and click it to trigger the agent to ‘run on server’
Dim s As New NotesSession
Dim agent As NotesAgent
Set DB = s.CurrentDatabase
Set agent = DB.GetAgent("TestCreateTable")
Call agent.RunOnServer
Error
====
You will get the error - “Missing RichTextParagraphStyle object” in the Notes Log.
%END REM
Dim s As New NotesSession
Dim db As NotesDatabase
Dim Doc As NotesDocument
Dim ParaStyle_Array(1 To 2) As NotesRichTextParagraphStyle
Dim rtpStyle As NotesRichTextParagraphStyle
Dim rtpStyle2 As NotesRichTextParagraphStyle
Set db = s.CurrentDatabase
Set Doc = db.CreateDocument
Dim Body As New NotesRichTextItem(Doc, "Body")
Set rtpStyle = s.CreateRichTextParagraphStyle
rtpStyle.RightMargin = RULER_ONE_CENTIMETER
rtpStyle.FirstLineLeftMargin = 0
rtpStyle.LeftMargin = 0
Set ParaStyle_Array(1) = rtpStyle
Set rtpStyle2 = s.CreateRichTextParagraphStyle
rtpStyle2.RightMargin = RULER_ONE_CENTIMETER * 2
rtpStyle2.FirstLineLeftMargin = 0
rtpStyle2.LeftMargin = 0
Set ParaStyle_Array(2) = rtpStyle2
Call body.AppendTable(3,2, , ,ParaStyle_Array)
Call Doc.Save(True, True)
'Any help is much appreciated!!!
End Sub