save as pdf and email

RedOctoberKnight

Board Regular
Joined
Nov 16, 2015
Messages
150
Office Version
  1. 2016
Platform
  1. Windows
Good Morning all,

I see that this question has been asked multiple times but I just cant seem to get it work for my needs. I found the following code online and have been slightly tweaking it using a scrap workbook. The problem is it doesn't do everything I'd like it to do. What I have is a workbook with multiple worksheets that contain payroll for that day (each sheet is it's own day). My ultimate goal is to be able to click a button and have it save a specified range on that selected sheet as a .pdf and then email it to the appropriate address. I would also like it to save each .pdf as the name in a specified cell on each sheet (lets say B1) in the following folder "H:\mci-sup\Excel\STAFFING\Daily Exception logs-SENT" As always, any help would be much appreciated.

VBA Code:
Sub Send_Email()

Range("N37").Value = Application.UserName

    Dim wPath As String, wFile As String
    
    wPath = ThisWorkbook.Path
    wFile = Range("A1").Value & ".pdf"
    Range("J1:Q35").ExportAsFixedFormat Type:=xlTypePDF, Filename:=wPath & wFile, _
        Quality:=xlQualityStandard, IncludeDocProperties:=True, _
        IgnorePrintAreas:=False, OpenAfterPublish:=False


    Set dam = CreateObject("Outlook.Application").CreateItem(0)
    '
    dam.To = "email address"
    dam.cc = "email address"
    dam.Subject = "MCI PROVO EXCEPTION LOG - " & Range("A1").Value
    dam.Body = "See attached"
    dam.Attachments.Add wPath & wFile
    dam.display
    'MsgBox "Email sent"


End Sub
 

Excel Facts

Save Often
If you start asking yourself if now is a good time to save your Excel workbook, the answer is Yes

Forum statistics

Threads
1,215,219
Messages
6,123,688
Members
449,117
Latest member
Aaagu

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top