JiggersBass
New Member
- Joined
- May 20, 2022
- Messages
- 13
- Office Version
- 365
- 2010
- Platform
- Windows
To who it may concern,
I was assisted here on creating an email where I can paste a table or an image of the table using the below code, but I cannot find a way to insert my signature, the command line would always turn red. I also find it hard to keep the format of the table to fit contents all the time.
Private Sub CommandButton1_Click()
Dim r As Range
Set r = Range("a1:g13")
r.Copy
Dim outlookApp As Object
Set outlookApp = CreateObject("Outlook.Application")
Dim outMail As Object
Set outMail = outlookApp.CreateItem(0)
Dim strBody As String
strBody = "Hi Team," & vbNewLine & vbNewLine & _
"Kindly see below attendance for my team:"
With outMail
.display
.To = Range("a15").Value
.cc = Range("a16").Value
.Subject = Range("a17").Value
.body = strBody
Dim wordDoc As Object
Set wordDoc = .GetInspector.WordEditor
End With
With wordDoc
.Application.Selection.EndKey Unit:=6 'wdStory
.Application.Selection.TypeParagraph
.Application.Selection.PasteAndFormat 10 'wdChartPicture
End With
'To paste as a table
'wordDoc.Range.PasteExcelTable LinkedToExcel:=False, WordFormatting:=False, RTF:=False
End Sub
I was assisted here on creating an email where I can paste a table or an image of the table using the below code, but I cannot find a way to insert my signature, the command line would always turn red. I also find it hard to keep the format of the table to fit contents all the time.
Private Sub CommandButton1_Click()
Dim r As Range
Set r = Range("a1:g13")
r.Copy
Dim outlookApp As Object
Set outlookApp = CreateObject("Outlook.Application")
Dim outMail As Object
Set outMail = outlookApp.CreateItem(0)
Dim strBody As String
strBody = "Hi Team," & vbNewLine & vbNewLine & _
"Kindly see below attendance for my team:"
With outMail
.display
.To = Range("a15").Value
.cc = Range("a16").Value
.Subject = Range("a17").Value
.body = strBody
Dim wordDoc As Object
Set wordDoc = .GetInspector.WordEditor
End With
With wordDoc
.Application.Selection.EndKey Unit:=6 'wdStory
.Application.Selection.TypeParagraph
.Application.Selection.PasteAndFormat 10 'wdChartPicture
End With
'To paste as a table
'wordDoc.Range.PasteExcelTable LinkedToExcel:=False, WordFormatting:=False, RTF:=False
End Sub
Attachments
Last edited: