Arkadaslar
Userformda ,Listview penceresinde bulunan faturalari asagidaki kod ile emaile PDF formatinda ekleyebiliyorum. Listview peneceresindeki her faturanin Excel Sayfa("Multi") de E sutunuda numarasi ve F Sutununda da sistemdeki directory adresi var.
Asagisaki kod E sutundaki fatura numaralarinin karsisindaki F sutununda bulunan directory link'lerini active ediyor ve Word formatinda olan faturalari PDF'e cevirip tek tek emaile ekliyor. Bunlarda hic bir sorun yok.
Bu faturalari bir PDF dosyasi olarak ekleyebilirmiyim?
Saygilar sunuyorum
Private Sub MultipleAttach_Click()
Dim R As Range, fnd As Range, fn As String, fnPDF As String
Dim Ref1 As Long
Dim StrSignature As String
Dim sPath As String
Dim EmailBody As String
Dim OutApp As Object
Dim OutMail As Object
Dim strBody As String
Dim inv As String, invPDF As String
Dim ws As Worksheet
Dim dic As Object
sPath = "C:\Users\" & Environ("username") & "\AppData\Roaming\Microsoft\Signatures\Signature.htm"
If Dir(sPath) <> "" Then
StrSignature = GetSignature(sPath)
Else
StrSignature = ""
End If
On Error Resume Next
Set ws = Worksheets("Multi")
Application.Calculation = xlCalculationManual
Application.ScreenUpdating = False
'Create e-mail item
Set OutApp = CreateObject("Outlook.Application")
Set OutMail = OutApp.CreateItem(0)
With OutMail
Set dic = CreateObject("Scripting.Dictionary")
For i = 1 To Range("E65536").End(3).Row
If Cells(i, "E") <> "" Then dic.Add Cells(i, "E").Value, i
Next i
Ref1 = Join(dic.Keys, " ; ")
.BodyFormat = olFormatHTML
.To = ""
.CC = ""
.BCC = ""
.Subject = "Payment Reminder for " & Ref1
.Body = "Dear Sir" _
& vbCrLf & "" _
& vbCrLf & "Our records is showing that we haven't received payment for " & Ref1 _
& vbCrLf & "" _
& vbCrLf & "I will be grateful if you arrange payment for the attached invoices " _
& vbCrLf & ""
.HTMLBody = strBody & .HTMLBody & StrSignature
'.HTMLBody = "Here is the file you asked for"
For Each rng In Worksheets("Multi").Range("F2", Range("F2").End(xlDown))
invPDF = TempPDF(rng.Value)
MakeWordPDFFile rng.Value, invPDF
.Attachments.Add invPDF
Next
.Display
On Error GoTo 0
Set OutMail = Nothing
Set OutApp = Nothing
UserForm1.Show
'ThisWorkbook.RefreshAll
Application.Calculation = xlCalculationAutomatic
Application.ScreenUpdating = True
End With
End Sub
Userformda ,Listview penceresinde bulunan faturalari asagidaki kod ile emaile PDF formatinda ekleyebiliyorum. Listview peneceresindeki her faturanin Excel Sayfa("Multi") de E sutunuda numarasi ve F Sutununda da sistemdeki directory adresi var.
Asagisaki kod E sutundaki fatura numaralarinin karsisindaki F sutununda bulunan directory link'lerini active ediyor ve Word formatinda olan faturalari PDF'e cevirip tek tek emaile ekliyor. Bunlarda hic bir sorun yok.
Bu faturalari bir PDF dosyasi olarak ekleyebilirmiyim?
Saygilar sunuyorum
Private Sub MultipleAttach_Click()
Dim R As Range, fnd As Range, fn As String, fnPDF As String
Dim Ref1 As Long
Dim StrSignature As String
Dim sPath As String
Dim EmailBody As String
Dim OutApp As Object
Dim OutMail As Object
Dim strBody As String
Dim inv As String, invPDF As String
Dim ws As Worksheet
Dim dic As Object
sPath = "C:\Users\" & Environ("username") & "\AppData\Roaming\Microsoft\Signatures\Signature.htm"
If Dir(sPath) <> "" Then
StrSignature = GetSignature(sPath)
Else
StrSignature = ""
End If
On Error Resume Next
Set ws = Worksheets("Multi")
Application.Calculation = xlCalculationManual
Application.ScreenUpdating = False
'Create e-mail item
Set OutApp = CreateObject("Outlook.Application")
Set OutMail = OutApp.CreateItem(0)
With OutMail
Set dic = CreateObject("Scripting.Dictionary")
For i = 1 To Range("E65536").End(3).Row
If Cells(i, "E") <> "" Then dic.Add Cells(i, "E").Value, i
Next i
Ref1 = Join(dic.Keys, " ; ")
.BodyFormat = olFormatHTML
.To = ""
.CC = ""
.BCC = ""
.Subject = "Payment Reminder for " & Ref1
.Body = "Dear Sir" _
& vbCrLf & "" _
& vbCrLf & "Our records is showing that we haven't received payment for " & Ref1 _
& vbCrLf & "" _
& vbCrLf & "I will be grateful if you arrange payment for the attached invoices " _
& vbCrLf & ""
.HTMLBody = strBody & .HTMLBody & StrSignature
'.HTMLBody = "Here is the file you asked for"
For Each rng In Worksheets("Multi").Range("F2", Range("F2").End(xlDown))
invPDF = TempPDF(rng.Value)
MakeWordPDFFile rng.Value, invPDF
.Attachments.Add invPDF
Next
.Display
On Error GoTo 0
Set OutMail = Nothing
Set OutApp = Nothing
UserForm1.Show
'ThisWorkbook.RefreshAll
Application.Calculation = xlCalculationAutomatic
Application.ScreenUpdating = True
End With
End Sub
