Macro to print first 2 pages of current sheet as pdf and email

Tosborn

New Member
Joined
May 24, 2016
Messages
44
Macro to print first 2 pages of current sheet as pdf and email

Hey there,

Could someone please help me out with a macro. Need the macro to print out the first 2 pages of the active sheet as a pdf and save in a specified directory.

Could we then have another macro to complete the same as above but then also prepare an email with the pdf attached to the email. The email address to send to is stored in B12 of the active sheet.

We could also have the cc of the email and the body of the email also stored in U7 & U8 of the active sheet.

Thanks so much. This is gonna save me a bunch of time.

Love my mr. excel msg board, complete life saver.

Tim
 
Like this:

Code:
Sub CreateOutlook()
Dim wks As Worksheet, OutApp As Outlook.Application, OutMail As Outlook.MailItem, filestr$
Set wks = ActiveSheet
filestr = wks.[b15] & wks.[b16]            ' cell B15=c:\pub\              cell B16=bt.pdf
wks.ExportAsFixedFormat xlTypePDF, filestr, , , False, 1, 2, False
Set OutApp = CreateObject("Outlook.application")
Set OutMail = OutApp.CreateItem(olMailItem)
With OutMail
    .To = wks.[b12]
    .cc = wks.[b13]
    .BCC = "testing@live.com"
    .Subject = "Meet up to Discuss"
    .Body = wks.[b14]
    .Attachments.Add filestr
    .Display
End With
Set OutMail = Nothing
Set OutApp = Nothing
Application.ScreenUpdating = True
End Sub
 
Upvote 0

Excel Facts

Enter current date or time
Ctrl+: enters current time. Ctrl+; enters current date. Use Ctrl+: Ctrl+; Enter for current date & time.

Forum statistics

Threads
1,223,723
Messages
6,174,108
Members
452,544
Latest member
aush

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