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
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