PDA

View Full Version : VBA Convert Below outlook code to Late Binding....



malleshg24
09-05-2019, 03:01 PM
Hi Team,


Please assist me in converting below Outlook code into Late Binding.


Situation - 1


Dim doc As Word.Document
Set doc = mi.GetInspector.WordEditor ' How to Convert this line Late Binding


Situation -2


Dim olinsp As Outlook.Inspector
Dim wddoc As Word.Document
Set olinsp = .GetInspector '????? How to Convert this line Late Binding
Set wddoc = olinsp.WordEditor '?... How to Convert this line Late Binding


Thanks in advance


Regards,
mg

Leith Ross
09-05-2019, 07:31 PM
Hello naleeshg24,

I haven't tested this code but try it and let me know the results.



Option Explicit


Sub test()


Dim ol As Object
Dim mi As Object
Dim doc As Object
Dim msgbox As String

Const olMailItem As Long = 0

Set doc = CreateObject("Word.Application")
Set ol = CreateObject("Outlook.Application")

Set mi = ol.CreateItem(olMailItem)
mi.Display
mi.To = "ABC.COM"
mi.Subject = "movies"

Set doc = mi.GetInspector.WordEditor
msgbox = vbNewLine & vbNewLine & "Please Reply with question."
doc.Range(0, 0).InsertAfter msgbox

msgbox = vbNewLine & vbNewLine & "Please see chart Below:" & vbNewLine & vbNewLine

Sheet1.ChartObjects(1).Chart.ChartArea.Copy
doc.Range(0, 0).Paste
Application.CutCopyMode = False

doc.Range(0, 0).InsertAfter msgbox
Sheet1.Range("A1").CurrentRegion.Copy
doc.Range(1, 1).Paste
Application.CutCopyMode = False

msgbox = "Hi Team," & vbNewLine & vbNewLine & "Please see table below:" & vbNewLine

doc.Range.InsertBefore Text:=msgbox


End Sub

malleshg24
09-05-2019, 09:44 PM
Hi Leith,

It worked thanks for your help. I wanted word to be late binding, its working.:thumb


Regards,
mg

Leith Ross
09-06-2019, 01:27 AM
Hello malleshg24,

That's great to hear. Glad I could help.