Save Excel OLE Object to disk
9 views (last 30 days)
Show older comments
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 Comments
Answers (0)
See Also
Categories
Find more on Spreadsheets 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!