How to restrict picture in richtext field?

Hi All,

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.

Thanks & Regards,

Kumar.

Subject: How to restrict picture in richtext field ?

Hi

You cannot access rt fields on a new document. Rt fields does not yet exist. Try to put your code to Post Save event and check if it works.

Trevor

PS. You don’t have to get uidoc througth NotesUiWorkspace. Source.documents is enough

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.

Please help.

Regards,

Kumar.

Subject: RE: How to restrict picture in richtext field ?

OK. You cannot see any references to pasted pictures from document properties.

I don’t know if it works, but you could try NotesRichTextNavigator. Refer to Designer’s help for using it.

Subject: RE: How to restrict picture in richtext field ?

Hi, I have achieved the result atlast !

This can be done by creating a field with datatype “Rich Text Lite” and de-select the unnecessary options in 2nd tab of field properties.

In this case, I de-selected “Picture”, “Image”, “OLE” etc except “Attachment” and “Text”. So, when we click in this field, the menu will be disabled.

Thanks,

Kumar.