Why am I unable to edit the EMF-file I exported from MATLAB in Microsoft Word?

22 views (last 30 days)
I used the following code to generate an Enhanced Metafile (EMF)
figure ('renderer','painters')
z = peaks;
mesh(z);
colormap([0 0 0]);
print -dmeta peaks1.emf
I then place the "peaks1.emf" in a Microsoft Word document as follows:
Go to "Insert" menu in MS Word, and choose "Picture -> From File". Locate the "peaks1.emf" in the "Insert Picture" dialog box that opens, and click "Insert".
Unlike other metafiles, when I place "peaks1.emf" file in a Microsoft Word document, I am unable to edit this metafile by double-clicking on it (i.e., the file is treated as a bitmap rather than a vector-based graphic file).
I observe the same behavior if I insert the figure into MS Word using the Windows clipboard rather than explicitly exporting to a metafile. I follows these steps:
In the MATLAB figure window, I go to "Edit" menu and choose "Copy Figure". I then open a new MS Word document and insert the copied figure by choosing "Paste" from the "Edit" menu in MS Word. Although the figure is inserted, I am unable to edit its contents.

Accepted Answer

MathWorks Support Team
MathWorks Support Team on 23 Apr 2023
Edited: MathWorks Support Team on 24 Apr 2023
This is not a bug in MATLAB.
In order to be able to edit the exported EMF file follow the listed steps:
1. Make sure that you are using a vector renderer (i.e. "painters") for your figure. You can check the renderer for your current figure by issuing the following command at the MATLAB prompt:
get(gcf, 'renderer')
2. Ensure that the figure is set to export the vector information when you copy the figure using "Copy Figure" from the "Edit" menu. This can be done as follows:
In the figure, under "Edit -> Copy Options", ensure "Preserve Information" is selected.
Now, if you copy the file ("Edit -> Copy") or save the file as an Enhanced MetaFile (EMF) using the PRINT command as shown above,you will be able to edit it in MS Word. There is, however, a problem in the way MS Word handles metafiles. The metafile generated by the code above is not editable in Word 2003 (MS PowerPoint allows editing, but it creates some unnecessary lines in the process). This same file can be edited in other EMF editing programs such as Metafile Companion, downloadable from the following web site:
The problem in MS Word is related to the number of elements in the metafile. To illustrate the problem, run the following code in MATLAB:
figure ('renderer','painters')
z = peaks(35);
mesh(z);
colormap([0 0 0]);
print -dmeta peaks2.emf
This will produce fewer graphic elements than if you used "z=peaks;". If you insert "peaks2.emf" in an MS Word document following the steps described above, it can now be edited like other figures. In other words, MS Word does not allow the user to edit metafiles that have more than a certain number of elements. For workarounds, you should consult the MS Word documentation or contact Microsoft.

More Answers (0)

Categories

Find more on MATLAB Report Generator in Help Center and File Exchange

Products


Release

R14SP1

Community Treasure Hunt

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

Start Hunting!