Précédent   Forum des professionnels en informatique > Logiciels > Microsoft Office > Access
Access Forum d'entraide sur Microsoft Access. Avant de poster -> La F.A.Q Access
Partagez cette discussion sur d'autres réseaux sociaux : Viadeo Twitter Google Facebook Digg Delicious MySpace Yahoo
Réponse Proposer ce sujet en actualité
 
Outils de la discussion
Publicité
'
Vieux 05/09/2011, 12h23   #1
Invité régulier
 
Homme Ludo HARRAULT
Technicien CAO
Inscription : janvier 2007
Messages : 13
Détails du profil
Informations personnelles :
Nom : Homme Ludo HARRAULT
Localisation : France, Maine et Loire (Pays de la Loire)

Informations professionnelles :
Activité : Technicien CAO
Secteur : Industrie

Informations forums :
Inscription : janvier 2007
Messages : 13
Points : 6
Points : 6
Par défaut Problèmes après création PDF

Bonjour,
J'ai un bouton dans un formulaire qui me permet de créer un PDF et de l'envoyer par mail. J'ai fait 2 codes avec une légère variante sur chacun. Les 2 codes me donnent des résultats différents.
1er cas :
Le PDF est bien créé, envoie mail ok. Il m'ouvre Adobe Reader avec le document créé et je n'arrive pas à le refermer.
Code :
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
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
Dim Maildb          As Object
    Dim UserName        As String
    Dim MailDbName      As String
    Dim attachment      As String
    Dim rename          As String
    Dim subject         As String
    Dim recipient       As String
    Dim ccRecipient     As String
    Dim MailDoc         As Object
    Dim AttachME        As Object
    Dim Session         As Object
    Dim EmbedObj        As Object
    'Dim password        As String
    Dim objNotesField   As Object
 
    'Export PDF
DoCmd.OutputTo acOutputReport, "Certificat de Mesure LH", "PDFFormat(*.pdf)", "C:\Documents and Settings\truc\Desktop\" & Me.NumFab & ".pdf", True, , , acExportQualityScreen
 
    'Crée une session notes
    Set Session = CreateObject("Notes.NotesSession")
 
    attachment = rename
    subject = "Company " & Me![NumFab] & " - " & Me![NomCarte] & " - " & Me![NomCarte2]
    recipient = Me.Email
    ccRecipient = "a@a.com" & ", " & Me!CopieEmail
 
    'Récupère le nom d'utilisateur et crée le nom de la base des mails
    UserName = Session.UserName
    MailDbName = Left$(UserName, 1) & Right$(UserName, (Len(UserName) - InStr(1, UserName, " "))) & ".nsf"
 
    'Ouvre la base des mails
    Set Maildb = Session.GETDATABASE("", MailDbName)
    If Not Maildb.IsOpen Then Maildb.OPENMAIL
 
    'Paramètre le mail à envoyer
    Set MailDoc = Maildb.CREATEDOCUMENT
    MailDoc.Form = "Memo"
    MailDoc.SendTo = recipient
    MailDoc.CopyTo = Split(ccRecipient, ",")
    MailDoc.subject = subject
    Set objNotesField = MailDoc.CreateRichTextItem("Body")
    With objNotesField
        .AppendText "Dear Customer,"
        .AddNewLine 2
        .AppendText "Your stencil is cut, measured and ready for despatch (Please make sure your PO is already sent to us to organize the despatch on time !)."
        .AddNewLine 2
        .AppendText "Please find attached the COC&COA documents of your stencil."
        .AddNewLine 2
        .AppendText "We hope you will be satisfied with this product and our service."
        .AddNewLine 2
        .AppendText "Best Regards - Stencils Team Company FRANCE"
     End With
    MailDoc.SAVEMESSAGEONSEND = SaveIt
 
 
    'Prend en compte les pièces jointes
    rename = Me!NumFab & ".pdf"
 
    Set AttachME = MailDoc.CreateRichTextItem("Attachment")
    Set EmbedObj = AttachME.EMBEDOBJECT(1454, "", "C:\Documents and Settings\harraultl\Desktop\" & rename, "Attachment")
 
    'Envoie le mail
    MailDoc.PostedDate = Now()
    MailDoc.Send 0, recipient
 
    Set Maildb = Nothing
    Set MailDoc = Nothing
    Set AttachME = Nothing
    Set Session = Nothing
    Set EmbedObj = Nothing
 
DoCmd.Close acForm, "Saisie Certificat Mesure"
DoCmd.Close acReport, "Certificat de Mesure LH"
DoCmd.Close acForm, "Modification Enregistrement"
 
 
End Sub
2eme cas :
Le PDF est bien créé, envoie mail ok. Adobe Reader s'ouvre avec le message suivant "Une erreur est survenue lors de l'ouverture. Fichier introuvable"
Code :
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
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
Dim Maildb          As Object
    Dim UserName        As String
    Dim MailDbName      As String
    Dim attachment      As String
    Dim rename          As String
    Dim subject         As String
    Dim recipient       As String
    Dim ccRecipient     As String
    Dim MailDoc         As Object
    Dim AttachME        As Object
    Dim Session         As Object
    Dim EmbedObj        As Object
    'Dim password        As String
    Dim objNotesField   As Object
 
    'Export PDF
    DoCmd.OutputTo acOutputReport, "Certificat de Mesure LH", "PDFFormat(*.pdf)", "C:\Documents and Settings\truc\Desktop\Certificat de Mesure LH.pdf", True, , , acExportQualityScreen
 
    'Crée une session notes
    Set Session = CreateObject("Notes.NotesSession")
 
    attachment = rename
    subject = "Company " & Me![NumFab] & " - " & Me![NomCarte] & " - " & Me![NomCarte2]
    recipient = Me.Email
    ccRecipient = "a@a.com" & ", " & Me!CopieEmail
 
    'Récupère le nom d'utilisateur et crée le nom de la base des mails
    UserName = Session.UserName
    MailDbName = Left$(UserName, 1) & Right$(UserName, (Len(UserName) - InStr(1, UserName, " "))) & ".nsf"
 
    'Ouvre la base des mails
    Set Maildb = Session.GETDATABASE("", MailDbName)
    If Not Maildb.IsOpen Then Maildb.OPENMAIL
 
    'Paramètre le mail à envoyer
    Set MailDoc = Maildb.CREATEDOCUMENT
    MailDoc.Form = "Memo"
    MailDoc.SendTo = recipient
    MailDoc.CopyTo = Split(ccRecipient, ",")
    MailDoc.subject = subject
    Set objNotesField = MailDoc.CreateRichTextItem("Body")
    With objNotesField
        .AppendText "Dear Customer,"
        .AddNewLine 2
        .AppendText "Your stencil is cut, measured and ready for despatch (Please make sure your PO is already sent to us to organize the despatch on time !)."
        .AddNewLine 2
        .AppendText "Please find attached the COC&COA documents of your stencil."
        .AddNewLine 2
        .AppendText "We hope you will be satisfied with this product and our service."
        .AddNewLine 2
        .AppendText "Best Regards - Stencils Team Company FRANCE"
     End With
    MailDoc.SAVEMESSAGEONSEND = SaveIt
 
 
    'Prend en compte les pièces jointes
 
    rename = "COOKSON " & Me![NumFab] & " - " & Me![NomCarte] & " - " & Me![NomCarte2] & ".pdf"
    Name "C:\Documents and Settings\truc\Desktop\Certificat de Mesure LH.pdf" As "C:\Documents and Settings\truc\Desktop\" & rename
 
    Set AttachME = MailDoc.CreateRichTextItem("Attachment")
    Set EmbedObj = AttachME.EMBEDOBJECT(1454, "", "C:\Documents and Settings\Truc\Desktop\" & rename, "Attachment")
 
 
    'Envoie le mail
    MailDoc.PostedDate = Now()
    MailDoc.Send 0, recipient
 
    Set Maildb = Nothing
    Set MailDoc = Nothing
    Set AttachME = Nothing
    Set Session = Nothing
    Set EmbedObj = Nothing
 
 
DoCmd.Close acForm, "Saisie Certificat Mesure"
DoCmd.Close acReport, "Certificat de Mesure LH"
DoCmd.Close acForm, "Modification Enregistrement"
 
 
End Sub
J'image que la solution est simple mais cela fait tellement de temps que je suis dessus que je ne la vois pas !!!
Merci d'avance pour votre aide.
mumuludo est déconnecté   Envoyer un message privé Réponse avec citation 00
Vieux 05/09/2011, 12h35   #2
Expert Confirmé
 
Homme Philippe
ex Observeur CGG / Analyste prog.
Inscription : juin 2006
Messages : 1 703
Détails du profil
Informations personnelles :
Nom : Homme Philippe
Localisation : France, Finistère (Bretagne)

Informations professionnelles :
Activité : ex Observeur CGG / Analyste prog.

Informations forums :
Inscription : juin 2006
Messages : 1 703
Points : 3 624
Points : 3 624
Salut, via Taskkill http://technet.microsoft.com/en-us/l.../bb491009.aspx ?
et qqch comme
Code :
1
2
Dim RetVal As Long
    RetVal = Shell("Taskkill /im AcroRd32.exe /f", 0)
__________________
Pensez à Voter, d'avance merci. ( Pouces en bas à la droite de Citer )
Balisez votre code après l'avoir indenté sous Excel via Smart Indenter
Autre utilitaire : MZ Tools 3.0 VBA

Contribution : Excel / Word / PDF avec Adobe Acrobat Pro / PDFCreator 1 2
kiki29 est déconnecté   Envoyer un message privé Réponse avec citation 00
Vieux 05/09/2011, 13h44   #3
Invité régulier
 
Homme Ludo HARRAULT
Technicien CAO
Inscription : janvier 2007
Messages : 13
Détails du profil
Informations personnelles :
Nom : Homme Ludo HARRAULT
Localisation : France, Maine et Loire (Pays de la Loire)

Informations professionnelles :
Activité : Technicien CAO
Secteur : Industrie

Informations forums :
Inscription : janvier 2007
Messages : 13
Points : 6
Points : 6
Merci beaucoup pour l'info, cela fonctionne parfaitement.
mumuludo est déconnecté   Envoyer un message privé Réponse avec citation 00
Réponse Proposer ce sujet en actualité Cette discussion est résolue.
Outils de la discussion



Fuseau horaire GMT +2. Il est actuellement 17h05.


 
 
 
 
Partenaires

Hébergement Web