How to automate the conversion of an Excel file to a PDF document and email the PDF document via Outlook automatically using VBA.
Complete code and sample file available here:
For more knowledge read the book Excel 2016 Power Programming with VBA:
If you are from India you can get this book here: …(read more)
Convert Word 2 PDF: Word to PDF Converter
Convert PowerPoint 2 PDF: PPT to PDF Converter
Convert Excel 2 PDF: Excel to PDF Converter
Convert an Image 2 PDF: Image to PDF Converter
Convert HTML 2 PDF: HTML to PDF Converter
More Tools: PDF Converter
awesome video. how to add on in this vba with adding password on the exported pdf? also is there a way to automate different password to different client or recipient name?
Thank you. This solved a problem I have bee struggling with ever since I created my invoice
Hello Mr Takyar, great video !!! In order to send an email I need to have my Outlook already open. Otherwise this HTML Emails sits somewhere and waits for OutLokk mail to be opened. How can I deal with that ?
i want to prepare a checklist for team and until the whole team signs the checklist the macro should throw an error while sending the email. Sir it would be really helpful if you can please guide me with this
I have created a macro in my personal workbook but when I saved it(macro enabled) in a shared path my teammates are unable to run the macro and there is no VBA found in their system. Please help me to fix this
need invoce no. in subject line
How to do iteration for multiple files in excel ( for loop ? )
I have simply followed Your instructions and all works perfectly ! Thanks for sharing Your knowledge.
If I want my pdf attachment with today's date , what should be done??
Air kya hum ise whatsapp par pdf share karna chahe to kaise kar sakte hai??
Sub Sanction_Letter()
'
' Sanction_Letter Macro
'
ChDir "D:Sanction Letters"
ActiveWorkbook.ExportAsFixedFormat xlTypePDF, "D:Sanction Letters" & Sheet2.Range("Companyname").Value & ".pdf", , , False, 2, 11, fasle
Dim OutLookApp As Object
Dim OutLookMailItem As Object
Dim myAttachments As Object
Set OutLookApp = CreateObject("Outlook.application")
Set OutLookMailItem = OutLookApp.CreateItem(0)
Set myAttachments = OutLookMailItem.Attachments
With OutLookMailItem
.To = Sheet1.Range("TO")
.CC = Sheet1.Range("CC")
.Subject = "sanction letter for sheet2.Range(companyname)"
.Body = “Pleas”
myAttachments.Add "D:Sanction Letters & (sheet2.range(companyname).value & .pdf"
.send
End With
Set OutLookMailItem = Nothing
Set OutLookApp = Nothing
MsgBox ("Sanction letter has been generated successfully")
End Sub
getting an error cannot find this file, verify the path and file name are correct- please suggest how to write query for file path.
how can i directly directly generate salary slip from excel as PDF as send as gmail attachment without using Microsoft outlook?
Thanks a lot sir, this has helped a lot… God bless you!
How can I do it via IBM notes
Hi Dinesh
Every coding is perfect but sending mail is not received in the recipient mail address. Please help me to get a solution. Thank you. Sujay
Very good video thank you!
One question, how can I automate this process without me having to be in excel? I would like this email/pdf attachment to automatically send to staff 30 days before a particular date in the Excel document?
This would serve as an automated email reminder from Excel that a task we are tracking in Excel has 30 days to be completed.
Thanks
Its so helpful for me but how to do when alots of person with different mail ID to send pdf file like this? Plz guide me.
how to upload a pdf file and save in to a folder using VBA
Dear Dr Takyar,
Is there a way to print a PDF file with VBA? I am using windows 10 , 32 bit version, and excel 2010. I searched much, but unable to find a working method.
Thank you.
Piyal Fernando (Sri Lanka)
Thank you very much Dr. I met your videos only in last week and they help me to improve my knowledge in VBA =, Thank you so much again. Piyal Fernando (Sri Lanka)
I am using ms excel 2007 and word 2003 when I am copying your vba code its not working kindly fix it
Sir, very useful but i am getting error in the line : ActiveSheet.ExportAsFixedFormat Type:=xlTypePDF, Filename:="C:EXCEL_PDFtest_save.pdf”, OpenAfterPublish:=True"
Invalid procedure call or argument.. can u pls help me out