I Am Selecting a Particular range in excel file using Select range activity and pasting it in MSPaint Application using ctrl+V hotkey, Some times Copied Image is not Pasted in Paint Application without the image the paint file is saved what is the reason

Anyone give your suggestion to resolve it.

If you just want to save Range as Image then you can try below in invoke code (vb.net)


Dim objApp As Microsoft.Office.Interop.Excel.Application = New Microsoft.Office.Interop.Excel.Application()
ObjApp.Visible= False
Dim objSheet As Microsoft.Office.Interop.Excel._Worksheet = DirectCast(objApp.Workbooks.Open("C:\Temp\Test.xlsx",False,True).Worksheets("Sheet1"),Microsoft.Office.Interop.Excel._Worksheet)
Dim range As Microsoft.Office.Interop.Excel.Range = objSheet.Range("B2:C6")

range.CopyPicture(Microsoft.Office.Interop.Excel.XlPictureAppearance.xlScreen, Microsoft.Office.Interop.Excel.XlCopyPictureFormat.xlPicture)

Dim oChtobj As Microsoft.Office.Interop.Excel.ChartObject = DirectCast(objSheet.ChartObjects,Microsoft.Office.Interop.Excel.ChartObjects).Add(CDbl(range.Left), CDbl(range.Top), CDbl(range.Width), CDbl(range.Height))
Dim oCht As Microsoft.Office.Interop.Excel.Chart = oChtobj.Chart

oCht.Paste()
oCht.Export(Filename:="C:\Temp\Test_" & now.ToString("HHmmss") & ".jpg")
oChtobj.Delete()
objApp.ActiveWorkbook.Close(False)
ObjApp.Visible= True
ObjApp.Quit

Create arguments for excel file path and Range.
You will need to have Microsoft.Office.Interop.Excel dependency installed

Let us know if you need any clarification