MATLAB Answers

How can I copy a graph in excel and paste it into word?

18 views (last 30 days)
Thomas Lee
Thomas Lee on 12 Jun 2016
Answered: Image Analyst on 13 Jun 2016
I would like to copy a graph I made in an Excel file (there is only one graph in a file) and paste it onto a single Word file.
Instead of opening an excel file and pasting it onto a word file manually, I am trying to do this using MATLAB.
Can anyone help me do this? It seems like a relatively simple task but I'm not much of a MATLAB person.
Thank you.


Show 7 older comments
Marc on 12 Jun 2016
Why would you do this? Seriously? Let's say you have 70mb of data stuck in Excel AND you have Matlab.... Just grab the data in excel and plot the stuff in Matlab. Then you can use the publish functions of Matlab to automate reporting. If you have the excel add on toolbox, you can highlight data, right click and send it right over to Matlab for plotting. I guess I am baffled why you would ever do this IF you have Matlab? Seems like an awfully expensive thing to do since VBA and Microsoft can already talk to each other.
Thomas Lee
Thomas Lee on 12 Jun 2016
The chart can end up in word as an image, no issue there.
As to why I want to do this, I have an many excel files with extensive calculations already done - which is why these files are so large. They have become very slow - almost 5 minutes to open, copy the chart into word as image, and close the file.
The graph is quite involved as it has jittering with layers of data with particular formatting and I would not want to reproduce the same graph in matlab when they are already produced in excel.
If it seems VBA would work better, I will look into it.
Marc on 13 Jun 2016
Good luck... In my experience, excel only gets bulkier and in many cases kills computers. I work with data historians and people like to dump endless streams of second by second data into them... Useless.
Regardless, getting your data out of excel, running the calcs and plotting the results in Matlab is way better than coming up with some macro to keep the data stuck in excel. In my experience, a 70mb .mat file loads in Matlab effortlessly and you can quickly set up what if scenarios.
Bite the bullet, do yourself and the future of humanity a favor... Recreate the calcs in Matlab, allowing you to use an endless amount of functions/tools to improve you work processes.

Sign in to comment.

Answers (3)

Guillaume on 12 Jun 2016
This is not really a matlab question as the code you'd write in matlab would be the same VBA code you'd write in Excel / Word to do the same thing. Plus, if it's just one graph it'd be faster to do it manually anyway.
In the end you've got to use Excel and Word object model. Probably the best way for you to find what the code should be would be to record a macro in excel where you copy the graph, and record a macro in word where you paste. The code in the macro would be the same you'd write in matlab.


Sign in to comment.

Image Analyst
Image Analyst on 13 Jun 2016
You can control both Excel and Word with ActiveX. I attach an example of how to communicate with Excel. You can do the same thing with Word. Basically the easy way to do it is to record a macro in Excel or Word and then edit the macro to see what it did. Then copy those lines of code to MATLAB. You may have to make a few slight modifications but at least you find out the methods you need to call.


Sign in to comment.


Community Treasure Hunt

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

Start Hunting!

Translated by