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 36 37 38 39 40 41 42 43 44 45 46 47 48
| Private Sub David_Click()
On Error GoTo erreur
Dim objoutlook As Outlook.Application
Dim olns As Outlook.NameSpace
Dim mItem As Outlook.MailItem
Dim att As Outlook.Attachment
Dim fld As Outlook.MAPIFolder
'Création de l'objet Outlook
Set objoutlook = CreateObject("Outlook.application")
'Récupération de l'espace de nom d'outlook
Set olns = objoutlook.GetNamespace("MAPI")
'Récupération du répertoire "boite de réception" par défault
Set fld = olns.GetDefaultFolder(olFolderInbox)
'importer le fichier joint dans le répertoire actuel
For Each mItem In fld.Items
For Each att In mItem.Attachments
If att.FileName = "BasketPersoDavidData.mdb" Then
att.SaveAsFile CurrentProject.Path & "\" & att.FileName
End If
Next att
Next mItem
'supprimer les anciennes tables de David
DoCmd.DeleteObject acTable, "SignalétiqueDavid"
DoCmd.DeleteObject acTable, "PrestationsDavid"
'attacher les tables de David
DoCmd.TransferDatabase acLink, "Microsoft Access", _
CurrentProject.Path & "\BasketPersoDavidData.mdb", acTable, _
"Signalétique", "SignalétiqueDavid"
DoCmd.TransferDatabase acLink, "Microsoft Access", _
CurrentProject.Path & "\BasketPersoDavidData.mdb", acTable, _
"Prestations", "PrestationsDavid"
'détecter les différences éventuelles entre les signalétiques
If DCount("clé", "DiffGabyDavidSignalétique") <> 0 Then
DoCmd.OpenForm "ComparaisonSignalétique"
End If
'détecter les propositions d'équipe
If DCount("Datum", "DiffGabyDavidPrestations") <> 0 Then
DoCmd.OpenForm "PropositionEquipe"
Else
MsgBox "Il n'y a pas de proposition de David", vbExclamation, "Importation des Propositions d'équipe"
End If
Exit Sub
erreur:
Select Case err.number
Case 2046 'la table xxxDavid n'existe pas
Resume Next
End Select
End Sub |
Partager