|
Invité régulier
 Ludo HARRAULT Technicien CAO Inscription : janvier 2007 Messages : 13 Détails du profil  Informations personnelles : Nom :  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
|
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.
|