Attacher un fichier

Attacher un fichier

Messagepar Michael DELIQUE » 23 Nov 2006 à 13:12

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
Cordialement

Michael (SMS-Phobique)
----------------------------
"La théorie, c'est quand on sait tout et que rien ne fonctionne. La pratique, c'est quand tout fonctionne et que personne ne sait pourquoi."
Albert EINSTEIN
Avatar de l’utilisateur
Michael DELIQUE
Administrateur
Administrateur
 
Message(s) : 12183
Inscrit(e) le : 16 Déc 2004 à 10:36
Localisation : Paris/Cergy

Messagepar Wildcat » 26 Juil 2010 à 14:40

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 !"
Avatar de l’utilisateur
Wildcat
Premier posts
Premier posts
 
Message(s) : 19
Inscrit(e) le : 06 Jan 2010 à 11:11
Localisation : Montpellier

Messagepar Michael DELIQUE » 26 Juil 2010 à 21:09

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
Cordialement

Michael (SMS-Phobique)
----------------------------
"La théorie, c'est quand on sait tout et que rien ne fonctionne. La pratique, c'est quand tout fonctionne et que personne ne sait pourquoi."
Albert EINSTEIN
Avatar de l’utilisateur
Michael DELIQUE
Administrateur
Administrateur
 
Message(s) : 12183
Inscrit(e) le : 16 Déc 2004 à 10:36
Localisation : Paris/Cergy


Retour vers Gestion de fichiers