bonjour à tous j'ai un petit code qui me permet d'enregitre des piece jointe là ou je veux, qui marche tres bien, j'ai voulu l'améliorer pour les séparer en fonction de leur nom et j'ai un bug qui dit: " erreur d''exécution 424 objet requis" sur la ligne : if attach.filename
dite mois que je suis bête et que c'etait tout simple..
voici mon code
merci beaucoup de votre aide
Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35 Dim ObjItem As Object Dim ObjMail As Outlook.MailItem Dim myolApp As New Outlook.Application Dim myOlExp As Outlook.Explorer Dim myOlSel As Outlook.Selection Dim MsgTxt As String Dim x As Integer MsgTxt = "Vous devez selectionner un seul mail" Set myOlExp = myolApp.ActiveExplorer Set myOlSel = myOlExp.Selection x = myOlSel.Count If x <> 1 Then MsgBox MsgTxt Exit Sub End If 'ca c'est pour l'afficher Set attachs = myOlSel.Item(x).Attachments If attach.FileName Then For Each attach In attachs file = attach.FileName attach.SaveAsFile "Z:\SESSIONS\CQP\2020\S67MC_01-2020\region\prescription\" & file Next Else For Each attach In attachs file = attach.FileName attach.SaveAsFile "Z:\SESSIONS\CQP\2020\S67MC_01-2020\region\CV_et_LDM\" & file Next End If End Sub
Partager