I am trying to create a new memo using COM from Visual Basic (is this groundhog day?).Anyway, it’s OK I can access the mailfile.
And I can create a new document.
And I can set the Subject, and Save the document.
However, I can’t access the Body field.
And, when I open the document, the Body field is not there in the document properties until I save the document in the UI (perhaps LotusScript backend has the same issue).
Of course I need to use all BackEnd because UI is not supported in COM…
Here is some code, any ideas? Cheers.
'Do lots of other things related to Excel
'Then Declare some Domino Objects
Dim domSession As Object
Set domSession = CreateObject(“Lotus.NotesSession”)
Dim domDatabase As Object
Dim domDocument As Object
Dim domViewEntry As Object
Dim domView As Object
Dim domViewNav As Object
Dim domUIDocument As Object
Dim strName As String
Dim DesignField As NOTESRICHTEXTITEM 'Variant 'Object
Dim sEffortField
'Intialize the session
domSession.Initialize
'Get the users mailfile
Dim dir As Object
Set dir = domSession.GETDBDIRECTORY(“”)
Set domDatabase = dir.OpenMailDatabase
'Create a memo and save it
Set domDocument = domDatabase.CREATEDOCUMENT
Call domDocument.Save(True, True)
Call domDocument.REPLACEITEMVALUE(“Subject”, TitleAsText)
Call domDocument.Save(True, True)
Set DesignField = domDocument.GETFIRSTITEM(“Body”)
'domDocument.Subject = “New building”
Call domDocument.Save(True, True, True)
====
If I add a watch, the DesignField is set to Nothing here:
Set DesignField = domDocument.GETFIRSTITEM(“Body”)
And then later in the code I get an error trying to access it:
Call DesignField.APPENDSTYLE(richStyle)
Run Time error 91, Object variable or With block variable not set.
I am supposing this error is because DesignField is set to Nothing, but should be set to something, and I am supposing that is because the field is not accessible until the document is saved in the UI?
Does someone have an idea?