Matlab to MSWord function library

Version 1.0.0 (1.77 MB) by fhz
A organized library of functions to write MSWord documents direct from Matlab.
Updated 16 Feb 2020

View License

Functions are highly based on:
Andreas Karlsson (2019). WriteToWordFromMatlab;
Stefan Braun (2019). ActiveX Word control base commands;
Ivar Eskerud Smith (2020). Control MS Word from matlab.

Many of them are the definition of specialized funtions or improvements on the original ones, specially the functions to create tables and figures.

There is a script as a complete example of all functions and the main options.

Every function has examples

Create a new MSWord file or open an existent.
Enable the visibility of the file. It is faster with visualization.
If it opens an existent file there an option to go to the end of the file.

Close the file and save it. Andreas Karlsson (2019).

Write a text with options such as: emphasis, align and color.
Options are given in the comments.

For ASCII symbol insertion. Andreas Karlsson (2019).

Prints a list of methods. Andreas Karlsson (2019).

The function to create tables inserting data from a cell array.
Its core comes from Andreas Karlsson (2019).
This function adds the options to align the table and the data inside it,
it may remove cell borders and apply the ones you define (not so many option right now, but enough to good results),
and merge columns or rows (but not both at the same time).

Write the total number of pages on footer or header with a given alignment.

Insert n page breaks. Ivar Eskerud Smith (2020).

The list of options is given as a comment.
Andreas Karlsson (2019).
Ivar Eskerud Smith (2020).

Prepare Font Name and Size for non-style text inputs.
Prepare the page setup. Stefan Braun (2019).

figure_clipboard_into_word and figure_saved_into_word:
Two techniques to insert figures. Andreas Karlsson (2019).

fc_lib_msword_allfigures_into_Word and fc_lib_msword_allfigures_into_Word_caption:
Update from figure_saved_into_word that inserts all figures of a given list.
It has options to define new labels, to insert captions above or below from the figure and to resize the figure.
The list of figures may be automatically created with the function:
from my "File Manipulation Library".
(This is necessary because package has different objectives and should not mix).
It still can be manually typed, but will not be as efficient as it could.

Create the Table of Contents. Andreas Karlsson (2019).

Cite As

fhz (2024). Matlab to MSWord function library (, MATLAB Central File Exchange. Retrieved .

MATLAB Release Compatibility
Created with R2017a
Compatible with any release
Platform Compatibility
Windows macOS Linux
Find more on Environment and Settings in Help Center and MATLAB Answers

Community Treasure Hunt

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

Start Hunting!
Version Published Release Notes