I have this code and is all perfect and running very smoothly, just need a change so that after body the copy past so be done. currently it is doing but copy pasting is over writing the text.
Any solution.
Any solution.
VBA Code:
Sub EmailBodyENOCFixed()
Dim outlookApp As Object
Dim outlookMail As Object
Dim ws As Worksheet
Dim rng As Range
Dim pic As Object
Windows("Hourly Pending Tickets V1.xlsm").Activate
Sheets("Pending Tickets with ENOC Fixed").Select
Set ws = ThisWorkbook.Sheets("Pending Tickets with ENOC Fixed")
Set rng = ws.UsedRange
If Not rng Is Nothing Then
Set outlookApp = CreateObject("Outlook.Application")
Set outlookMail = outlookApp.CreateItem(0)
With outlookMail
.Body = Sheets("Email").Range("C7").Value
.To = Sheets("Email").Range("C2").Value
.CC = Sheets("Email").Range("C3").Value
.BCC = Sheets("Email").Range("C4").Value
.Subject = Sheets("Email").Range("C5").Value
End With
rng.CopyPicture xlScreen, xlBitmap
outlookMail.GetInspector.WordEditor.Range.Paste
On Error Resume Next
Set pic = outlookMail.GetInspector.WordEditor.Range.InlineShapes(1)
On Error GoTo 0
If pic Is Nothing Then
On Error Resume Next
Set pic = outlookMail.GetInspector.WordEditor.Range.Shapes(1)
On Error GoTo 0
End If
If Not pic Is Nothing Then
pic.LockAspectRatio = msoFalse
'pic.Height = 700
'pic.Width = 1800
pic.Height = rng.Height * 1
pic.Width = rng.Width * 1
Else
MsgBox "Unable to find the pasted picture.", vbExclamation
End If
outlookMail.Display
Application.Wait (Now + TimeValue("0:00:03"))
' outlookMail.Send
Else
MsgBox "No used cells in the specified range", vbInformation
End If
End Sub