Clear Filters
Clear Filters

Save Excel OLE Object to disk

15 views (last 30 days)
Afzal
Afzal on 20 Feb 2020
Edited: Afzal on 21 Feb 2020
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

Answers (0)

Categories

Find more on Data Export to MATLAB in Help Center and File Exchange

Products


Release

R2016b

Community Treasure Hunt

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

Start Hunting!