Sequence4.xaml (10.2 KB)
ConvertImageToBase64.xaml (6.0 KB)
- download sequence4.xaml and convertImagetoBase64.xaml to your project folder
- put below code in text file (vba.txt)
- open sequence4.xaml
a. change imgPath to your own path (MUST BE JPG)
b. update send outlook activity and use imgHtmlString in body, remember to tick isBodyHTML
Function exportTableAsImage(imageFilePath As String)
Sheets("data").Activate
Dim rng As Range
Set rng = Range("A1:J" & Range("A" & Rows.Count).End(xlUp).Row)
Dim i As Integer
Dim intCount As Integer
Dim objPic As Shape
Dim objChart As Chart
Dim width As Integer, height As Integer
width = 1200 '10 inches
height = 360 '5 inches
Call rng.CopyPicture(xlScreen, xlPicture)
Dim Sheet2 As Worksheet
Set Sheet2 = ActiveWorkbook.Sheets.Add
'remove all previous shapes in sheet2
intCount = Sheet2.Shapes.Count
For i = 1 To intCount
Sheet2.Shapes.Item(1).Delete
Next i
'create an empty chart in sheet2
Sheet2.Shapes.AddChart
'activate sheet2
Sheet2.Activate
'select the shape in sheet2
Sheet2.Shapes.Item(1).Select
Set objChart = ActiveChart
'paste the range into the chart
objChart.Paste
objChart.Parent.width = width
objChart.Parent.height = height
'save the chart as a JPEG
objChart.Export (imageFilePath)
End Function
Sub TestIt()
exportTableAsImage ("a.jpg")
End Sub