I'm working on a lotus script code that extracts attachments from documents. The code works fine except for a few documents and throws an error: Error Code:91 - Error: Object variable not set
Below is the code I'm using to do the extraction:
If (doc.HasItem("$File")) Then
attachments = Evaluate("@AttachmentNames", doc)
Forall o In attachments
Set AttachmentName = doc.GetAttachment(o)
Call AttachmentName.ExtractFile(Attachfoldername & "\" & AttachFileNames)
End Forall
End If
On debugging I found that the AttachmentName variant is not getting set and just shows [NOTESEMBEDDEDOBJECT] value for it once I step into the next line. Please see screen print below: AttachmentName variable not set
Also you can see from the above image that the attachment name contains certain junk characters. There were few other documents for which the code failed and returned the same error. All of these had attachments with file names having strange characters (Ex.: "■ß■■1.jpg", "AR Médipel faible teneur en capasaïcine.doc").
There are no rich text fields in the form that is used and I do not have access to see the design of the form but I can see the $FILE field in the document properties. I initially thought that problem could be with the file name, so for testing this I attached a file with the same name into a rich text field of a test document. This time the code worked successfully extracting the attachment as expected. So now I'm left wondering what might be the actual problem.
I'm a beginner with Lotus Script so I don't know if I'm missing something.
Any help to resolve this would be greatly appreciated. Thanks in advance!