Hi everyone,
I have an agent that runs on selected document to have their attached file extracted to a directory who’s value is stored in a profile document. I keep getting an error message telling me that a variable object is not set. I’ve rechecked the code and everything seems ok. Can anyone spot the problem? Any help would be appreciated. My debugger stops at the line that has the following code:
downloadfolder = profileAttach_ServerName.Text & profileAttach_Directory.Text
Here is the agent’s script code:
Sub Initialize
Dim session As New NotesSession
Dim db As NotesDatabase
Dim object As NotesEmbeddedObject
Dim collection As NotesDocumentCollection
Dim doc As NotesDocument
Dim ProfileDoc As NotesDocument
Dim downloadfolder As String
Set db = session.CurrentDatabase
Set collection = db.UnprocessedDocuments
Dim profileAttach_ServerName As NotesItem
Dim profileAttach_Directory As NotesItem
Set ProfileDoc = db.GetProfileDocument("Extraction Settings")
Set profileAttach_ServerName = ProfileDoc.GetFirstItem("Attach_ServerName")
Set profileAttach_Directory = ProfileDoc.GetFirstItem("Attach_Directory")
‘downloadfolder = "H:\” & “Attachments"
downloadfolder = profileAttach_ServerName.Text & profileAttach_Directory.Text
If Dir(profileAttach_ServerName.Text + profileAttach_Directory.Text,16)="" Then Mkdir(profileAttach_ServerName.Text + profileAttach_Directory.Text)
Print "************************************************************************"
For i = 1 To collection.Count
Set doc = collection.GetNthDocument( i )
filen=Evaluate("@AttachmentNames",doc)
antalfiler=Evaluate("@Attachments", doc)
If Dir(profileAttach_ServerName.Text + profileAttach_Directory.Text + Format(Now(), "Long Date") ,16)="" Then Mkdir (profileAttach_ServerName.Text + profileAttach_Directory.Text + Format(Now(), "Long Date") )
Print Str(i)+" ("+Str(collection.count)+")"
If antalfiler(0)>0 Then
For filecounter=0 To antalfiler(0)-1
x=x+1
Print ( filen(filecounter))
Set Object = doc.GetAttachment( filen(filecounter) )
If ( object.Type = EMBED_ATTACHMENT ) Then
fileCount = fileCount + 1
If Dir(downloadfolder + Format(Now(), "Long Date") +"\"+ filen(filecounter))="" Then
extrachar=""
Else
extrachar=Left(doc.universalid,4)+"---" 'in case attachment with same name exists in several documents
End If
Call object.ExtractFile (downloadfolder+"\"+ Format(Now(), "Long Date") +"\"+extrachar+ filen(filecounter) )
End If
Next filecounter
End If
Next
Msgbox Str(fileCount ) + " Attachments were detached to the Attachments folder located in your Home directory (H:\Attachments) on " + Format(Now(), "Long Date") +"."
End Sub