Save Excel OLE Object to disk

9 次查看(过去 30 天)
Afzal
Afzal 2020-2-20
编辑: Afzal 2020-2-21
I have a spreadsheet with two jpeg files embedded in it. I would like to extract these and write them to a specific directory. I can do this in VBA as:
Sub Macro1()
ActiveSheet.Shapes.Range("Photo Object 1").Select
Selection.Copy
DestinationFolder = "C:..."
CreateObject("Shell.Application").Namespace(CVar(DestinationFolder)).self.InvokeVerb "Paste"
ActiveSheet.Shapes.Range("Photo Object 2").Select
Selection.Copy
CreateObject("Shell.Application").Namespace(CVar(DestinationFolder)).self.InvokeVerb "Paste"
End Sub
I'd like to do the same through MATLAB. So far what I've got the following:
Excel = actxserver('Excel.Application');
fullFileName = 'C:\....xls';
invoke(Excel.Workbooks, 'Open', fullFileName);
Workbook = Excel.ActiveWorkbook;
Worksheets = Workbook.sheets;
objects=Worksheets.Item(1).OLEObjects;
image1=Item(objects,1); % This is photo object 1
image2=Item(objects,2); % This is photo object 2
Copy(image1)
objShell = actxserver('Shell.Application');
DestinationFolder = 'C:\';
objFolder = objShell.NameSpace(DestinationFolder);
objFolderItem = objFolder.Self;
I can't work out how to paste the copied image from the system clipboard to a directory

回答(0 个)

产品


版本

R2016b

Community Treasure Hunt

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

Start Hunting!

Translated by