After printing to PDFs. How do I attach them to an email?

C

Calle

I use this code to print sheets to pdf files but how do I code a VBA macro to
attach the files to an email

s = Application.ActivePrinter
For i = 1 To 9
Err.Clear
On Error Resume Next
Application.ActivePrinter = "Adobe PDF på Ne0" & i & ":"
If Err.Number = 0 Then Exit For
On Error GoTo 0
Next
On Error GoTo 0
Worksheets("Kund data").PrintOut Copies:=1, ActivePrinter:= _
"Adobe PDF på Ne0" & i & ":", Collate:=True
Worksheets("Schakt dörr").PrintOut Copies:=1, ActivePrinter:= _
"Adobe PDF på Ne0" & i & ":", Collate:=True
Worksheets("Korg dörr").PrintOut Copies:=1, ActivePrinter:= _
"Adobe PDF på Ne0" & i & ":", Collate:=True

Application.ActivePrinter = s

I have tried this script but you have to define the name of the pdf. Is
there anyway to get the macro to know what file names and filepaths the new
pdfs I just created have?

Dim OutApp As Outlook.Application
Dim OutMail As Outlook.MailItem
Dim strbody As String
Dim cell As Range

Set OutApp = CreateObject("Outlook.Application")
Set OutMail = OutApp.CreateItem(olMailItem)

With OutMail
..To = ""
..CC = ""
..BCC = ""
..Subject = ""
..Attachments.Add ("C:\wittur\offert.pdf")
..Body = strbody
..Display
End With
Set OutMail = Nothing
Set OutApp = Nothing
 
T

Tom Ogilvy

I don't have acrobat installed here, so I can't test it and tell - also,
Acrobat seems to have multiple ways to do this. In any event, this is an oft
discussed topic, so you might look here and see if you can find something
that helps:

http://tinyurl.com/q8fyd
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top