par Michael DELIQUE » 14 Juin 2012 à 15:21
essais ça, mais je suis pas du tout convaincu que ça t'aidera.
- Code : Tout sélectionner
Public Function FileOleToPJ(wDoc As notesdocument, Byval wChamp As String,wDirectory As String, Byval wnbDelete As Boolean, Byval wnbSave As Boolean)As Variant
Dim rtitem As NotesRichTextItem
Dim lstValue List As String
Dim i As Integer
Dim vrEO As Variant
Dim vrObjet As Variant
Dim FileName As String
Dim PathFile As String
On Error Goto CatchError
lstValue(0) = ""
If wDoc Is Nothing Then
Error 9999,"wDoc is Nothing"
Else
If wDoc.HasEmbedded = False Then
FileOleToPJ = lstValue
Erase lstValue
Exit Function
End If
End If
If Trim(wChamp) = "" Then
Error 9999,"wChamp Empty"
Exit Function
Else
Set rtitem = wDoc.GetFirstItem(wChamp)
If rtitem Is Nothing Then
Error 9999,"rtitem => ''"+wChamp+"'' is nothing"
Exit Function
Else
If (rtitem.Type <> RICHTEXT) Then
Error 9999,"'"+wChamp+"'' is not NotesRichTextItem"
Exit Function
End If
End If
End If
If Trim(wDirectory) = "" Then
Error 9999,"wDirectory empty"
Exit Function
Else
If Right(Trim(wDirectory),1)<>"\" Then
wDirectory = Trim(wDirectory)+"\"
Else
wDirectory = Trim(wDirectory)
End If
End If
If Trim(wChamp) = "" Then
vrEO = wDoc.EmbeddedObjects
Else
vrEO = rtitem.EmbeddedObjects
End If
i=0
If testVariant(vrEO) = True Then
Forall Attachement In vrEO
If Attachement.Type = EMBED_OBJECT Then
FileName = "File"+Cstr(i)
PathFile = wDirectory+FileName
Set vrObjet = Attachement.Activate(False)
On Error Resume Next
vrObjet.Application.Windows( vrObjet.Application.Windows.Count).Visible = True
On Error Goto CatchError
Call vrObjet.SaveAs(PathFile)
Call vrObjet.Close
REM 2 maniere différente de sortir
On Error Resume Next
Call vrObjet.Quit
Call vrObjet.Application.Quit
On Error Goto CatchError
Set vrObjet= Nothing
If wnbDelete = True Then
Call Attachement.Remove
End If
Call rtItem.EmbedObject ( EMBED_ATTACHMENT, "", PathFile)
Call FileKill (PathFile,False)
lstValue(i) = FileName
i=i+1
End If
End Forall
vrEO = Null
End If
Set rtitem = Nothing
If wnbSave = True Then
Call wDoc.Save(True,False)
End If
FileOleToPJ = lstValue
Erase lstValue
Exit Function
CatchError:
MsgBox "("+Structure_Log+" : "+Cstr(GetThreadInfo (1))+" Call by "+Cstr(GetThreadInfo(10))+")"+Chr(10)+"Error " + CStr(Err) + " : "+Chr(10) + CStr(Error)+". "+Chr(10)+"Line # "+Cstr(Erl),16," ERROR !"
lstValue(0) = "ERROR"
FileOleToPJ = lstValue
Erase lstValue
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