Macro to print PDF file

Status
Not open for further replies.

KarelDeGrote

New Member
Joined
Dec 11, 2018
Messages
8
Hi all,

I have created a macro piece by piece using this form, but now I am stuck with it, hope someone can help.
I have macro which is used to send a pdf file to an email address if the cell containing the email address do have a value.
Now I would like to add a code to print the pdf file on a default printer if the cell is blank. So send an email when there is an email address and print the pdf file when the cell with email address is empty (and send by regular mail).

Code:
Sub SendEmailfromOutlook()


Sheets("Email list").Activate


Dim OutApp As Object
Dim OutMail As Object
Dim cell As Range
Dim Path As String

Path = Application.ActiveWorkbook.Path
Set OutApp = CreateObject("Outlook.Application")

For Each cell In Range("j3:j50")
If cell.Value <> "" Then


Set OutMail = OutApp.CreateItem(0)
With OutMail
.SentOnBehalfOfName = "test@test.com"
.To = cell.Value
.Subject = Cells(cell.Row, "A").Value
.Body = "Dear Sir/ Madam," _


.Attachments.Add (Path & "\" & Cells(cell.Row, "L").Value)
'.Send
.Save
End With
End If
Next cell


End Sub
 

Excel Facts

Lock one reference in a formula
Need 1 part of a formula to always point to the same range? use $ signs: $V$2:$Z$99 will always point to V2:Z99, even after copying
Duplicate https://www.mrexcel.com/forum/excel-questions/1080436-macro-printing-pdf-file.html#post5190812

Please do not post the same question multiple times. All clarifications, follow-ups, and bumps should be posted back to the original thread.
Per forum rules, posts of a duplicate nature will be locked or deleted (rule 12 here: Forum Rules).

Note that sometimes posts from new users require Moderator approval before you can see them on the public forums. When this happens, you should see a message to that effect when you try to post it.
Please be patient and do not attempt to post the question again.

 
Upvote 0
Status
Not open for further replies.

Forum statistics

Threads
1,214,925
Messages
6,122,301
Members
449,078
Latest member
nonnakkong

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