Replacing an image in excel
Show older comments
Hello everyone, I know how to write an image to a specific location/cell in Excel using Matlab, but I am having a really hard time finding or building a script that can exchange a specific image on a specific sheet.
Here's the first bit of code:
%Start Active X Server
xlApp = actxserver('Excel.Application');
xlApp.visible = 1;
%Open the the spreadsheet
xlworkbook = xlApp.Workbooks.Open([pwd,'\New.xls']);
%Select sheet:
Sheet = get(xlworkbook.Sheets,'Item',7); % sheet
Sheet.Select;
%Work in Sheet
xlsheet = xlworkbook.ActiveSheet;
xlsheet.Shapes.Item(1).Select
As can be seen, using the Activex commands, I was able to get as far as selecting the specific shape on a sheet, but after that I'm stuck, as I can't find any proper documentation on how to replace the selected image (i.e. .shape).
Thanks a lot!
2 Comments
Kevin Chng
on 7 Sep 2018
I'm not sure. Do you mind try this?
xlsheet.Shapes.Fill.UserPicture ("C:\image.png")
I'm not sure. however, sometimes, i will take this link as guideline.
Sven Henrich
on 7 Sep 2018
Accepted Answer
More Answers (0)
Categories
Find more on Use COM Objects in MATLAB in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!