Youseepooo
New Member
- Joined
- Feb 5, 2019
- Messages
- 37
Hello,
I have this code that sends out an email via a button, however my last table is not appearing when it publishes as PDF. I made sure the table is within the range of the code but it still inst appearing. Any suggestions?
I have this code that sends out an email via a button, however my last table is not appearing when it publishes as PDF. I made sure the table is within the range of the code but it still inst appearing. Any suggestions?
Code:
Sub Send_Email()
Dim dam As Object
Dim wPath As String
Dim wFile As String
Dim x As String
Dim wf As WorksheetFunction
Dim myRange As String
Dim strPathToImageFolder As String
Dim strImageFilename As String
Dim strHTML As String
Set wf = Application.WorksheetFunction
x = Format(wf.WorkDay(Date, 1), "MMMM dd, yyyy")
wPath = "J:\Schedules\PCC Daily Schedule\2019 March"
wFile = "Daily Look Ahead for " & x & ".pdf"
Range("B1:G82").ExportAsFixedFormat Type:=xlTypePDF, Filename:=wPath & "\" & wFile, _
Quality:=xlQualityStandard, IncludeDocProperties:=True, _
IgnorePrintAreas:=False, OpenAfterPublish:=False
ActiveSheet.PageSetup.PrintArea = myRange
With ActiveSheet.PageSetup
.LeftMargin = Application.InchesToPoints(0.5)
.RightMargin = Application.InchesToPoints(0.5)
.TopMargin = Application.InchesToPoints(0.5)
.BottomMargin = Application.InchesToPoints(0.5)
.HeaderMargin = Application.InchesToPoints(0.2)
.FooterMargin = Application.InchesToPoints(0.1)
.PaperSize = xlPaperA4
.Orientation = xlPortrait 'xlLandscape
.Zoom = False
.FitToPagesWide = 1
.FitToPagesTall = False
End With
strPathToImageFolder = "C:\Users\ymussa\Pictures\Camera Roll"
If Right(strPathToImageFolder, 1) <> "\" Then
strPathToImageFolder = strPathToImageFolder & "\"
End If
strImageFilename = "pcc.jpg"
strHTML = "<p>Hello all,</p>"
strHTML = strHTML & "<p>The Daily Look Ahead Schedule for " & x & " is attached.<p><p>"
strHTML = strHTML & "<br>Thank You<br>Yousef Mussa<br>Assistant Engineer<br><img src=""cid:" & strImageFilename & """><p> Perfetto Contracting Co. Inc.<br>152 - 41 St Street<br>Brooklyn, NY 11232</p>Office: 718-858-8600 Ext. 166<br>Fax: 718-858-8604<br>E Mail: ymussa@perfettocontracting.com"
Set dam = CreateObject("Outlook.Application").CreateItem(0)
With dam
.to = "ymussa@perfettocontracting.com;sascoli@perfettocontracting.com;JNascimento@perfettocontracting.com;TBucciarelli@perfettocontracting.com;broe@perfettocontracting.com;rtitov@perfettocontracting.com;jsilko@perfettocontracting.com;jmiranda@perfettocontracting.com;cperfetto@perfettocontracting.com;cperfettojr@perfettocontracting.com;ppopielarski@perfettocontracting.com;fmarriott@perfettocontracting.com;PFiguera@perfettocontracting.com;nzarelli@perfettocontracting.com;acolandro@perfettocontracting.com "
.cc = "mperfetto@perfettocontracting.com;AEmirtepe@perfettocontracting.com;hmohammed@perfettocontracting.com;TBolgiani@perfettocontracting.com"
.Subject = "Daily Schedule for " & x
.attachments.Add wPath & "\" & wFile
.attachments.Add strPathToImageFolder & strImageFilename
.htmlbody = strHTML
.display
End With
Set dam = Nothing
MsgBox "Email sent"
End Sub