Hello!
I'm new to VBA, this is honestly my first time playing around in it, and I need some assistance.
I have a group of cells on my excel sheet that I want to have copied and pasted into the email body, but everything I try comes up with nothing. Could anyone help? I also really need my Outlook signature to populate with these emails, too. Some codes I tried before wouldn't keep it, this one seems to somehow!
I'm so sorry if this post is incorrect as well. Desperation makes me panic!
Also: The way my code is currently, I believe was going to use Word to paste a "picture" of the data, but I need the values, not just a photo. I hope this makes sense, and thank you in advance!
I'm new to VBA, this is honestly my first time playing around in it, and I need some assistance.
I have a group of cells on my excel sheet that I want to have copied and pasted into the email body, but everything I try comes up with nothing. Could anyone help? I also really need my Outlook signature to populate with these emails, too. Some codes I tried before wouldn't keep it, this one seems to somehow!
I'm so sorry if this post is incorrect as well. Desperation makes me panic!
Also: The way my code is currently, I believe was going to use Word to paste a "picture" of the data, but I need the values, not just a photo. I hope this makes sense, and thank you in advance!
VBA Code:
Sub PasteStatsToEmail()
'Declare Outlook Variables
Dim oLookApp As Outlook.Application
Dim oLookItm As Outlook.MailItem
Dim oLookIns As Outlook.Inspector
'Declare Word Variables
Dim oWrdDoc As Word.Document
Dim oWrdRng As Word.Range
'Declare Excel Variables
Dim ExcRng As Range
On Error Resume Next
'Get The Active Instance of Outlook
Set oLookApp = GetObject(, "Outlook.Application")
'If error create a new instance of Outlook
If Err.Number = 429 Then
'Clear Error
Err.Clear
'Create a new instance of Outlook
Set oLookApp = New Outlook.Application
End If
'Create a new Email
Set oLookItm = oLookApp.CreateItem(olMailItem)
'Create reference to Excel Range
Set ExcRng = Sheet1.Range("R55:R81")
With oLookItm
'Define Info
.To = "myboss@mybossemail.com"
.CC = "myteam@myteamemail.com"
.Subject = "Comparisons " & Sheet1.Range("C2")
.Body = Sheet1.Range("R55:R81")
.Display
'Get Inspector
Set oLookIns = .GetInspector
'Get Word Editor
Set oWrdDoc = oLookIns.WordEditor
'Get Range from Doc
Set oWrdRng = oWrdDoc.Application.ActiveDocument.Content
oWrdRng.Collapse Direction:=wdCollapseEnd
'Add a new Paragraph and Insert Break
Set oWrdRng = oWdEditor.Paragraph.Add
oWrdRng.InsertBreak
'Copy Range
ExcRng.Copy
End With
End Sub