Use the following code in the Querysave event to prevent saving a document that exceeds size limits you want to impose.
To avoid getting an extra prompt to save the document when the limit is exceeded, you'll either want to use the formula "@If(@Command([FileSave]);@Command([FileCloseWindow])" or use a hidden, editable "SaveOptions" field on the form, with a default text value of "1". If you use the SaveOptions field, then enable the "fieldsettext" calls in the script below.
By submitting your email address, you agree to receive emails regarding relevant topic offers from TechTarget and its partners. You can withdraw your consent at any time. Contact TechTarget at 275 Grove Street, Newton, MA.
Dim ws As New NotesUIWorkspace Dim uidoc As NotesUIDocument Dim doc As NotesDocument Dim totalSize As Long Set uidoc = ws.CurrentDocument Set doc = uidoc.document Call uidoc.refresh(True) Dim rtitem As Variant Dim embedObjs As Variant Set rtitem = doc.getFirstItem("Body") embedObjs = rttem.embeddedObjects totalSize = 0 dim oneMB as long oneMB = 1048576 If Not Isempty(embedObjs) Then For i = 0 To Ubound(embedObjs) totalSize = totalSize + embedObjs(i). filesize If embedObjs(i).filesize > 2 * oneMB Then Msgbox("Your attachment '" + embedObjs(i).name +"' is " +Cstr(Round (embedObjs(i).filesize / oneMB,1)) +" mb. The limit is 2.0 mb.") continue = False 'Call uidoc.fieldsettext ("SaveOptions","0") End If Next If totalSize > 4 * oneMB Then Msgbox("Your total attachment size is " +Cstr(Round (totalSize / oneMB,1)) +" mb. The limit is 4.0 mb.") continue = False 'Call uidoc.fieldsettext("SaveOptions","0") End If End If