Hi Team,
Please assist in converting below outlooks and word library code to late binding.
Below is attempted Code.
Thanks
mg
Please assist in converting below outlooks and word library code to late binding.
Below is attempted Code.
Code:
Sub Outlook_Late_Binding()
Dim OutApp As Object
Dim OutMail As Object
Dim ProcurementStatusSh As Worksheet
Dim WorkStatusSh As Worksheet
Dim ProjectStatusSh As Worksheet
[B] Dim wordDocument As Word.Document[/B]
[B] Dim wordRng As Word.Range[/B]
Set OutApp = CreateObject("Outlook.Application")
Set OutMail = OutApp.CreateItem(0)
Set ProcurementStatusSh = ThisWorkbook.Sheets("Sheet1")
Set WorkStatusSh = ThisWorkbook.Sheets("Sheet2")
Set ProjectStatusSh = ThisWorkbook.Sheets("Sheet3")
On Error Resume Next
With OutMail
.Display
.To = "Recipient@email.com"
.Subject = "project - Today's EoD Status : " & Format(Date, "dd-mmm-yyyy")
[B] Set wordDocument = OutApp.ActiveInspector.WordEditor[/B]
[B] wordDocument.Range.Text[/B] = "Recipient," & vbNewLine & vbNewLine & _
"Table1," & vbNewLine & "Procurement status," & vbNewLine
ProcurementStatusSh.Range("A1").CurrentRegion.Copy
[B] Set wordRng = wordDocument.Range[/B]
[B] wordRng.Collapse Direction:=wdCollapseEnd[/B]
[B] wordRng.Collapse[/B]
[B] wordRng.PasteAndFormat wdFormatOriginalFormatting[/B]
[B] wordDocument.Range.InsertAfter [/B]vbNewLine & "Table2," & vbNewLine
WorkStatusSh.Range("A1").CurrentRegion.Copy
[B] Set wordRng = wordDocument.Range[/B]
[B] wordRng.Collapse Direction:=wdCollapseEnd[/B]
[B] wordRng.PasteAndFormat wdFormatOriginalFormatting[/B]
wordDocument.Range.InsertAfter vbNewLine & "Table3," & vbNewLine
ProjectStatusSh.Range("A1").CurrentRegion.Copy
[B] Set wordRng = wordDocument.Range[/B]
[B] wordRng.Collapse Direction:=wdCollapseEnd[/B]
[B] wordRng.PasteAndFormat wdFormatOriginalFormatting[/B]
wordDocument.Range.InsertAfter vbNewLine & "Let me know, if any." & vbNewLine & vbNewLine & "Thanks & Regards!!!"
.Display
End With
Set OutMail = Nothing
Set OutApp = Nothing
Application.CutCopyMode = False
End Sub
Thanks
mg