I am using the function, Shapes.AddPicture to insert an image in an excel file.
I am calling the routine something like this :
leftPlacement=450;
topPlacement=20;
imgWidth=350;
imgHeight=300;
Shapes.AddPicture([pwd '\' img] ,0,1,leftPlacement,topPlacement,imgWidth,imgHeight);
This works fine. However, the image masks the data in the file. In order to change the position, leftPlacement, topPlacement, imgWidth imgHeight have to be changed manually.
I am wondering, if there is a better way to do it to transparently place the image in the empty cells.
Shapes are not attached to individual cells in the Excel Worksheet – they float above them and have their own coordinates. If you want to float them above a particular cell, you can get the coordinates of that cell and use those.
So if you want to float it above cell C9, try
where xl is the variable containing your reference to the Excel application.
Note that if you subsequently resize, or otherwise move any of the cells, the position of the shape/image won’t change – you’ll need to reposition it again using the same method.