Hi,
I’ve got a Notes doc with two rich text fields. My lotusscript agent goes to each field and using a ForAll Loop grabs the filename and size of each embedded file. This works great if there is at least one in each field. When there isn’t one, I get a “Type Mismatch” error. I can’t figure out how to verify an array with at least one embedded file exists before doing the Forall Loop. I’ve tried assiging a variable to the first element of the array. But you get an error when one doesn’t exists. I’m new to using rich text items and embedded objects so please excuse the question if its relatively simple to answer. Thanks.
Subject: Determining whether an embedded object exists
For each of your RichText fields first look for any embedded object names, add them to an array, then use your forall loop:
'set array
dim ObjArray() as String
x=0
Set rtitem = doc.GetFirstItem( “RTFIELD1” )
If ( rtitem.Type = RICHTEXT ) Then
Forall o In rtitem.EmbeddedObjects
Messagebox( o.Name ) 'for testing
x=x+1
ObjArray(x)=o.Name
End Forall
End If
'also for your second RT Field here… you could
'either add to the existing array or append a
'second one for the second field
'…
'then if the array is not empty
if x >0 then
'…
'Put your Forall here
'…
else
'x would be zero if no array values
endif
If object values exist then your original ForAll statement will run
HTH
Geoff-
Subject: RE: Determining whether an embedded object exists
Thanks Jeff! I’ll keep this script in mind if I need it. I found another posting at this forum that seemed to do the trick for now. http://www-10.lotus.com/ldd/nd6forum.nsf/55c38d716d632d9b8525689b005ba1c0/d158ec245417605985256faf0061c30f?OpenDocument