Hi everyone,
I want to send an email with the following image, not as an attachment. image is taken from excel data.
Is there a way to do it?
Thanks in advance,
Test.xlsx (11.4 KB)
Hi everyone,
I want to send an email with the following image, not as an attachment. image is taken from excel data.
Is there a way to do it?
Thanks in advance,
Test.xlsx (11.4 KB)
Hi @Anil_G
How can I get images from data excel ?
please check the attached file.
Thank,
Test.xlsx (11.4 KB)
You can follow the below steps
Then you can use the above method to insert the generated image in email
Cheers
Hi,
How about using Modern SendEmail or Create HTML Content activity?
We can insert table from datatable to mail body, as the following.
(Please read datatable from Excel using ReadRange activity etc in advance)
@Yoichi
Do you have an alternative method for adding an image generated from Excel data to the body of an email?
Thank you.
Hi,
How about the following custom activity?
Regards,
I have one activity available, but I am unsure about its safety.
Hi,
The following topic might also help you.
Regards,
Sequence4.xaml (10.2 KB)
ConvertImageToBase64.xaml (6.0 KB)
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
Hi @jack.chan
This solution works, but it may not be highly optimized for larger data sets exceeding 10 columns. To handle this, the resizing process should be customized in the vba.txt file. Nevertheless, I appreciate your enthusiastic help and will select your answer as the solution.
Also I have 1 other solution using:
Regards,
TuanNNA
no problem, currently the height is set here (in vba code)
you can set it be dynamic and relative to # rows, but probably needs to do some testing to find optimal formula
roughly something like this
change the code:
width = 1200
height = 360
to
Dim width As Integer, height As Integer
width = 1200
Dim numRows as integer
numRows = Range("A" & Rows.Count).End(xlUp).Row - 1
height = numRows * 40
This topic was automatically closed 3 days after the last reply. New replies are no longer allowed.