VBA: Attach excel file as well PDF copy of same excle to an email on single button click in excel -
The VBA code to create a PDF file in Excel and attached to the button to me. I am thinking that it is possible to attach both PDFs and Excel files to an email with one click. Please find the below code which I am trying to modify .. bold section showing the two functions. Any suggestions or help greatly appreciated !! Thank you
Sub Button1_Click () as dim EmailSubject string EmailSignature String Dim Email_Body string dim olMailItem object as dim 'form object as dim objMail CurrentMonth string, string, PDFFile as DestFolder as as as dim as string as the olFormatHTML dim Email_To string, as Email_CC string Email_BCC string dim OpenPDFAfterCreating Boolean, AlwaysOverwritePDF as Boolean, DisplayEmail Boolean dim OverwritePDF VbM sgBoxResult as dim OutlookApp object, as as as OutlookMail object 'CurrentMonth = "" dim fName string as string as as eCode1, eCode2 as string, fNameLong as string '**************************************** ***** *************** you can change these variables ********* 'Excel funnel name Create = "user access request:" eCode1 = Sheet1.Range ( " B7 "). value Ikod 2 = range (" B7 "). value fNameLong = fName & amp; "" & Amp; Encoded 1 & amp; "-" & amp; ECode2 EmailSubject = "abs" Change it to change the theme of "e-mail this instead if you ever want to overwrite a PDF already exists: the current month until the end of subj line OpenPDFAfterCreating = false 'right or wrong AlwaysOverwritePDF = truth instead if you note you want to open PDF after making it 'is added tRUE or FALSE DisplayEmail = true' change it if you do not want e-mail before sending the e-mail address to your email address For e-mail There should be an address email tag = "ABC" Change this if you want to specify email. = Name XlTypePDF, file :: = PDFFile, Quality: = xlQualityStandard, IncludeDocProperties: = ActiveSheet.Range ( "H1") cell H1 Email_CC = "Xyzkcom" Email_BCC = "" 'Create PDF ActiveSheet.ExportAsFixedFormat type This is true for receiving emails, IgnorePrintAreas _: = false, OpenAfterPublish: OpenPDFAfterCreating ** DialogSendMail.Show ") Set OutlookMail = OutlookApp.CreateItem 'Set up an Outlook object and new mail message OutlookApp = CreateObject (" Outlook .application ") Create '(0)' create file excellence but another email is Application.Dialogs (xlDialogSendMail) .Show" xyz ", for fNameLong ** Display email and specify For Outlook, with the theme, etc., please display .Display. Campaign = Email_To .cc = Email_CC .bcc = Email_BCC .Subject = EmailSubject & CurrentMonth .Attachments.Add PDFFile then DisplayEmail = false then .Send`enter code here` finally ending with the end Sub
Comments
Post a Comment