Page 1 sur 1

Attacher un fichier

MessagePublié: 23 Nov 2006 à 13:12
par Michael DELIQUE
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

MessagePublié: 26 Juil 2010 à 14:40
par Wildcat
J'ai une erreur sur le ErreurHandle

Avec la ligne suivante c'est OK
Code : Tout sélectionner
Msgbox "(FileAttach :" +Cstr(Getthreadinfo (1))+")"+Chr(10)+"Erreur " + Str(Err) + " : "+Chr(10) + Cstr(Error)+". "+Chr(10)+"Ligne N° "+Cstr(Erl),16," ERREUR !"

MessagePublié: 26 Juil 2010 à 21:09
par Michael DELIQUE
oui un coquille lors du copié / collé

mais maintenant j'utilise un code plus générique qui évite d'avoir a renseigné le nom de la fonction