Sub supprimerPieceJointe()
Dim orst As DAO.Recordset
Dim bolOk As Boolean
'ofld.SaveToFile
Set orst = CurrentDb.OpenRecordset("Table1")
'Accède à la liste des pièces jointes
With orst.Fields("PJ").Value
'Parcours les PJ
While Not .EOF
'Si la piece se nomme test.txt, on la supprime
If .Fields("FileName") = "test.txt" Then
.Delete
bolOk = True
End If
'On passe au suivant
.MoveNext
Wend
End With
'avertit l'utilisateur
If bolOk Then
MsgBox "Pièces jointes supprimées"
Else
MsgBox "Aucune pièce jointe ne porte ce nom"
End If
End Sub
Partager