I have a form that contains a richtext field. User will open the document and may attach file or create/paste picture in the attachment field. However, while saving this document, the richtext field contents are validated and the document is restricted from saving if it contains a picture.
I have tried with below code to track the richtext field content. But I am not able to get the attached picture details. Instead, I am getting “Type mismatch” error. Also, the “EmbeddedObjects” is blank/nothing.
===Code Starts Here====
Dim w As New NotesUIWorkSpace
Dim session As New NotesSession
Dim uidoc As NotesUIDocument
Dim doc As NotesDocument
Dim Db As NotesDatabase
Set note = source.Document
Set Db = session.CurrentDatabase
Set s = New NotesSession
Set uidoc = w.CurrentDocument
Set doc = uidoc.Document
Dim item As Variant
Set item = doc.GetFirstItem(“Attach1”)
If Not Isempty(item.EmbeddedObjects) Then
Forall embobj In item.EmbeddedObjects
Select Case embobj.Type
Case EMBED_OBJECTLINK:
embobjType = "Object link"
Case EMBED_ATTACHMENT:
embobjType = "Attachment"
Case EMBED_OBJECT:
embobjType = "Object"
End Select
if embobjType = "Object" then
Messagebox "Cannot paste pictures."
Continue = False
end if
End Forall
End If
===Code Ends Here=====
The above code exists in Query Save event.
How to achieve this ? Please help me.
ps: If I save the document, a mail will be sent to approvers. So, I should not save until the above validation is passed.
Subject: RE: How to restrict picture in richtext field ?
Hi,
The picture object reference does not exists in document properties even when I save the document with picture in richtext field.
Because of this, the EmbeddedObjects is showing nothing.
What should I do, to get picture object reference that is pasted or attached thru – <Picture…> menu option in richtext field ?
To crosscheck my procedure: I have created a new form with only 1 richtext field. I have attached a picture through <Create —> Picture> menu option and saved the form. When I try to check the document properties, I did not see any reference to this picture object.