Save Excel OLE Object to disk

11 visualizzazioni (ultimi 30 giorni)
Afzal
Afzal il 20 Feb 2020
Modificato: Afzal il 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

Risposte (0)

Categorie

Scopri di più su Data Export to MATLAB in Help Center e File Exchange

Prodotti


Release

R2016b

Community Treasure Hunt

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

Start Hunting!

Translated by