placing image in specified cell in excel
이전 댓글 표시
Hello,
I'm trying to figure out how i can place an image in a specified cell range, specifically one that is merged and centered.
ideally i would like to place the upper left hand corner of the image in the upper left hand corner of the specified cell.
i'm currently using the following code to place the image into excel, with specified dimensions. i'm iterating through a loop to manually place them in a position using 'Points'. I would like to get away from having to increment the dimensions in the loop because it is causing a shift in my image over a large directory of images. attached is the code i'm using to add the picture and increment the dimension/placement of it.
barcodepics = Shapes.AddPicture([DIR '\Barcodes\' image] ,dimensions(2,1), dimensions(2,2),...
dimensions(2,3),dimf2, dimensions(2,5), dimensions(2,6)); %
UPDATE: i have found this function that will write a figure to a specified cell range, maybe this could be slightly altered to allow for an image pull from a directory?
UPDATE(2):
I have also found this piece of code w/ the following results:


I'm wondering if it would be possible to add this into my existing Shapes.AddPicture code?
댓글 수: 2
Rik
2020년 11월 20일
You can use the clipboard function to interact with the clipboard. (so you can read the images from the file, then use clipboard to copy the image to the clipboard, then use this ActiveX-server to paste it in your excel file)
Note that ActiveX controls will be removed at some point in the future and only(?) work on Windows. This mechanism will also fail if you touch your pc during execution (as changing the clipboard contents or interacting with Excel might mess up the result).
adam campbell
2020년 11월 20일
채택된 답변
추가 답변 (0개)
카테고리
도움말 센터 및 File Exchange에서 Use COM Objects in MATLAB에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!
