Mario Rossi ha scritto:
>
> con il comando
> DoCmd.OutputTo acOutputReport, "Fattura", acFormatPDF, PercorsoFinale & nomefile
> genero un file pdf in c:\fatture\001_2019.pdf
>
> poi con il comando
> DoCmd.SendObject acSendReport, "fattura", "PDFFormat(*.pdf)", Me.Email, , , oggetto, testo, True
>
> invio il report di nome "Fattura" in formato pdf alla mail del cliente, ma l'allegato si chiama "fattura.pdf" che è il nome del report
>
> si può inviare come allegato il file creato con il comando DoCmd.OutputTo che si chiamerà correttamente "001_2019.pdf" oppure si può cambiare nome da codice vba al file che viene generato e allegato con il comando sendobject?
Il tuo codice non manda come allegato il file che salvi ma direttamente
il report di Access. Non è possibile di mandare un file salvato con
SendObject. Dovresti usare un codice diverso di automazione di Outlook o
diversi altri metodi di mandare e-mail.
Se invece vuoi solo cambiare il nome del file allegato basta cambiare la
proprietà Caption del report, p.e.
Dim strRptName As String, strPDFName As String
strRptName = "Fattura"
strPDFName = "001_2019" 'o la variabile nomefile ma senza ".pdf"
DoCmd.OpenReport strRptName, acViewDesign, , , acHidden
Reports(strRptName).Caption = strPDFName
DoCmd.Close acReport, strRptName, acSaveYes
DoCmd.SendObject acSendReport, strRptName, acFormatPDF, Me!Email, , ,
Oggetto, Testo, True
--
Ciao
Karl
*********
http://www.AccessDevCon.com
Access FAQ:
http://www.donkarl.com/it