![]() Print to PDF Using Macro Button in Excel (5 Macro Variants)Ģ.How to Save Excel as PDF on One Page (3 Easy Methods).Excel Macro: Save as PDF with Date in Filename (4 Suitable Examples).Export Excel to PDF with Hyperlinks (2 Quick Methods).How to Convert Excel to PDF without Converter (5 Effective Methods).Read More: Excel VBA to Print As PDF and Save with Automatic File Name ![]() Lastly, check the circle before the Yes command and set up your email account. However, if you didn’t set up an outlook account, you may get this type of message.Īfter pressing the Next button, you’ll get the following message. Now, you need to press the Send button only. Attached file name: It will be the same as the file name.Īfter running the code (keyboard shortcut is F5), you’ll get the published pdf document first.įinally, you’ll get the Email input box where the PDF files are attached.Please find the PDF attachment of the Excel file. Email body: Describe briefly about the attachment e.g.Email subject: Don’t forget to add an attractive subject e.g.Email address: Enter the suitable email address.File name: Besides, specify the file name e.g.File path: You have to define the file path where you want to publish the PDF e.g.Attachments.Add "E:\Exceldemy\Sales Report March.pdf" ![]() So, the complete code will look as follows. Lastly, you may use the Attachments.Add method to add the published PDF document and close the statement by setting the EmaiItem and EmailApp as "E:\Exceldemy\Sales Report March.pdf" Step 04: Add the Published PDF and Close Statement ![]() Body = "Please find the PDF attachment of the Excel file" the email address, subject and email body using the MailItem object. Note: It is necessary to open Outlook, mainly an email app having versatile tasks, for sharing or sending email from Excel directly.Īlso, you need to assign the necessary email items e.g. Set myAttachments = EmailItem.Attachments Set EmailApp = CreateObject("Outlook.application") Next, you have to declare and set the following variables for sending the email automatically. Step 02: Declare and Set Variables to Send Email "E:\Exceldemy\Sales Report March.pdf", OpenAfterPublish:=True ChDir "E:\Exceldemy"ĪctiveSheet.ExportAsFixedFormat Type:=xlTypePDF, Filename:= _ Then, you have to utilize the ExportAsFixedFormat statement to publish the active sheet in PDF format. To do that, you can use the ChDir statement to specify the current folder. Then, insert the complete code (you’ll get the complete code at the end of Step 4).įirstly, you have to Print to PDF of your dataset available in the worksheet. ➜ Firstly, open a module by clicking Developer > Visual Basic (or press ALT F11). If you want to publish a single worksheet (where your dataset is available) to PDF and then send email, this method will be highly fruitful for you.īefore doing that you need to create a module to insert the VBA code. Print to PDF and Email for Single Worksheet And the rest method focuses on the same task in case of multiple worksheets.ġ. The first one presents the way of doing such a task for a single worksheet. Now, you need to print to a PDF first and then send an email in Excel VBA. ![]() The below Sales Mar Sheet refers to the Sales Report of Fruits in March month.Īnd, the below Sales Apr Sheet refers to the Sales Report of Fruits in April month. one is for the month of March and the other one represents April. Moreover, there are two Sales Reports i.e. Let’s introduce today’s dataset where the Sales Report of Fruits is given along with the necessary information e.g. 2 Cases to Print to PDF and Email Using Excel VBA ![]()
0 Comments
Leave a Reply. |