Copy from Excel and Save as Image in email body

Hi Bot Learner,

We use invoke code activity to convert selected range/pivotTable to an image,

Here you have the way to get an image from a a desired range:

  1. Invoked arguments:

  2. Invoked body:

Dim xlWorkBook As  Microsoft.Office.Interop.Excel.Workbook
Dim xlWorkSheet As Microsoft.Office.Interop.Excel.Worksheet
Dim xlRange As Microsoft.Office.Interop.Excel.Range

Try

app.DisplayAlerts=False
xlWorkBook=app.Workbooks.Open(filePath)
xlWorkSheet = CType(xlWorkBook.Sheets(SheetName), Microsoft.Office.Interop.Excel.Worksheet)
xlWorksheet.Range(Range).CopyPicture(Microsoft.Office.Interop.Excel.XlPictureAppearance.xlScreen, Microsoft.Office.Interop.Excel.XlCopyPictureFormat.xlBitmap)

System.Windows.Forms.Clipboard.GetImage.Save(ImagePath, System.Drawing.Imaging.ImageFormat.Jpeg)
xlWorkBook.Close

Console.WriteLine("Image placed in: " + ImagePath)

Catch e As Exception
	xlWorkBook.Close
exceptionMessage =exceptionMessage + e.Message
End Try

Regards