kshitij_dch
Active Member
- Joined
- Apr 1, 2012
- Messages
- 362
- Office Version
- 365
- 2016
- 2007
- Platform
- Windows
Hello All,
I am working on a macro which will Copy all Contents from Word Document in same format to outlook Email Body ,I have managed to get a code which is pasting data from excel as string only but not in a same format of word , any chance if i can get it in exact format that of word document ???
??
I am working on a macro which will Copy all Contents from Word Document in same format to outlook Email Body ,I have managed to get a code which is pasting data from excel as string only but not in a same format of word , any chance if i can get it in exact format that of word document ???
VBA Code:
Sub SendDocAsMsg()
Dim wd As Word.Application
Dim doc As Word.Document
Dim oOutlookApp As Outlook.Application
Dim oItem As Outlook.MailItem
On Error Resume Next
'Start Outlook if it isn't running
Set oOutlookApp = GetObject(, "Outlook.Application")
If Err <> 0 Then
Set oOutlookApp = CreateObject("Outlook.Application")
End If
On Error GoTo 0
Set wd = CreateObject("Word.Application")
wd.Visible = True
Set doc = wd.Documents.Open(Filename:="C:\Users\Sony\Desktop\Document.docx", ReadOnly:=True)
'Copy the open document
doc.Content.Select
Word.Selection.Copy
Set oItem = oOutlookApp.CreateItem(olMailItem)
With oItem
.To = "this@email.com"
.Subject = "K****ij Sharma"
.Body = Word.Selection
.Display
End With
doc.Close
wd.Quit
Set doc = Nothing
Set oItem = Nothing
Set oOutlookApp = Nothing
Set wd = Nothing
End Sub