Macro PDF then E-mail

garbology

New Member
Joined
Mar 26, 2015
Messages
18
I have a list of clients that I print bills to by-monthly. I would like to start e-mailing these bills PDF to the customers. Currently my print macro goes down through a list of people in column B Looks to Columns C-M if it sees red text it will print a bill with the owed payments. The Macro cycles down through the list of Customers and prints each one a bill on a sheet of paper. I would like to e-mail each person a bill in PDF to an e-mail address that is located in column U that corresponds with the client. Also I would like if there is not a e-mail address on file that it prints a hard copy. I'm not super fluent with VBA, but work my way through it over the years. I would upload a test workbook but I'm unsure how at the moment.
Excel_Test.png

SQL:
Sub Print_All_Customers_Single_Sheet()

Dim lrow As Long
Dim rng As Range

lrow = Sheets("Sum").Cells(Rows.Count, "B").End(xlUp).Row

For i = 3 To lrow
   ' Add the values to the sheets
   Sheets("Invoice_Single_Sheet").Range("B4").Value = Sheets("Sum").Cells(i, "B").Value
   ' Print it
   Sheets("Invoice_Single_Sheet").PrintOut
Next i

End Sub
 

Excel Facts

Enter current date or time
Ctrl+: enters current time. Ctrl+; enters current date. Use Ctrl+: Ctrl+; Enter for current date & time.
I Worked most of the night but I finally was able to figure out a code to save each invoice pdf and loop through all customers. I just now need to connect it to cell B8 (Holds the email address) and send if though email.

VBA Code:
Sub AAA()
Dim Fname   As String
Dim lrow As Long
Dim rng As Range
lrow = Sheets("Sum").Cells(Rows.Count, "B").End(xlUp).Row

For i = 3 To lrow
   ' Add the values to the sheets
   Sheets("Invoice_Single_Sheet").Range("B4").Value = Sheets("Sum").Cells(i, "B").Value
    ChDir "C:\Users\lilgs\OneDrive\Documents\"
    Fname = Range("B4").Value
    ActiveSheet.ExportAsFixedFormat Type:=xlTypePDF, Filename:=Fname _
        , Quality:=xlQualityStandard, IncludeDocProperties:=True, IgnorePrintAreas _
        :=False, OpenAfterPublish:=False
Next i
End Sub
 
Upvote 0

Forum statistics

Threads
1,223,896
Messages
6,175,263
Members
452,627
Latest member
KitkatToby

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