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
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
adam campbell 2020년 11월 20일
can you copy images in matlab to the clipboard without creating a figure / figure handle?
i'm trying to avoid using the figure handle because it adds white background to my image when i paste it.

댓글을 달려면 로그인하십시오.

 채택된 답변

추가 답변 (0개)

카테고리

도움말 센터File Exchange에서 Use COM Objects in MATLAB에 대해 자세히 알아보기

제품

릴리스

R2019b

질문:

2020년 11월 20일

답변:

2020년 11월 20일

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by