Inserting an image in an excel sheet using QTP !

  • Thread starter Thread starter Vishal
  • Start date Start date
V

Vishal

I need to insert an image in an excel sheet using my QTP script. Can
anyone help ?

Thanks
Vishal
 
QTP is what? If it is a COM-compatible scripting environment then you
could automate Excel to add the picture.
Record a mocro in Excel while adding a picture and you should be able
to use the code in your script (after creating a reference to the
Excel application).

Tim.
 
Dim xlobj,wbobj,wsobj,rcount,ccount,wbobj1,wsobj1
Set xlobj=createobject("excel.application")
Set wbobj=xlobj.workbooks.open("full path of excel sheet with extension",2)
Set wsobj=wbobj.worksheets.item("sheet1")
rcount=wsobj.usedrange.rows.count
ccount=wsobj.usedrange.columns.count
For i=1 to rcount
For j=1 to ccount
val=wsobj.cells(i,j)
MyCheck =IsEmpty(val)
If (MyCheck) then
'to insert image in any empty cell in sheet
xlobj.ActiveCell.Worksheet.Pictures.Insert("full path of image with extension")

end if
Next
Next
wbobj.save
xlobj.quit
Set xlobj=nothing


note::likewise you can add image in any particular specified cell of sheet also.just need to specify the cell(i.j)
 
Back
Top