- Code : Tout sélectionner
Public Function FileAttach(wDoc As NotesDocument,wChamp As String, Byval wPathFile As String, Byval wnbSave As Integer) As Integer
'Insert le fiichier passé en parametre dans le champ du document
'Déclaration Variables
Dim rtBody As NotesRichTextItem
On Error Goto ErreurHandle
FileAttach = True
If wDoc Is Nothing Then
Error 9999, "wdoc is Nothing"
FileAttach = False
Exit Function
End If
If Trim(wChamp) = "" Then
Error 9999, "wChamp is empty"
FileAttach = False
Exit Function
End If
' If isValideFile(wPathFile) = False Then
' Msgbox "Fichier introuvable :"+Chr(10)+Chr(10)+wPathFile
' FileAttach = False
' Exit Function
' End If
Set rtBody = wDoc.GetFirstItem( wChamp )
If rtBody Is Nothing Then
Set rtBody = wDoc.CreateRichTextItem( wChamp )
End If
If rtBody Is Nothing Then
Error 9999,"Le champ ''"+wChamp+"'' est introuvable"
FileAttach = False
Exit Function
Elseif rtBody.type <> 1 Then
Error 9999,"Le champ ''"+wChamp+"'' n'est pas Rich Text"
FileAttach = False
Exit Function
End If
Call rtbody.EmbedObject ( EMBED_ATTACHMENT, "", wPathFile)
If wnbSave = True Then
Call wdoc.save(True,True)
End If
Set rtBody = Nothing
Exit Function
ErreurHandle:
Msgbox "(FileAttach" : "+Cstr(Getthreadinfo (1))+")"+Chr(10)+"Erreur " + Str(Err) + " : "+Chr(10) + Cstr(Error)+". "+Chr(10)+"Ligne N° "+Cstr(Erl),16," ERREUR !"
Set rtBody = Nothing
FileAttach = False
Exit Function
End Function
