4.55

4.5 | 21 ratings Rate this file 53 Downloads (last 30 days) File Size: 14.7 KB File ID: #9112

WriteToWordFromMatlab

by Andreas Karlsson

 

23 Nov 2005 (Updated 15 Feb 2006)

Automatically create MS Word documents from Matlab with figures, tables, headers and text.

| Watch this File

File Information
Description

This m-file is a modification of the 'save2word'. It's an example of how to automatically create MS Word documents from MATLAB with figures, tables, headers and text.

The different basic functionalities to add text with different style and to add figures are broken into sub-functions that can be used in a simple way.

Acknowledgements

The author wishes to acknowledge the following in the creation of this submission:
saveppt, save2word
This submission has inspired the following:
wordreport

MATLAB release MATLAB 6.5.1 (R13SP1)
Other requirements Microsoft Word
Tags for This File  
Everyone's Tags
Tags I've Applied
Add New Tags Please login to tag files.
Comments and Ratings (22)
24 Jan 2006 E TK

Very nice, easy to use and intuitive interface. It does exactly what you would expect. Thanks for posting!

17 Feb 2006 Theo Venter

This is excellent. Thanks

11 Apr 2006 Dimitri Garbi

That is exactly what I was looking for. The code allow to generate generic reports automatically. Thank you !

note : Styles must be adapted in order to have no error. 'Heading 1' in english correspond to 'Rubrik 1' in swedish (as commented) and to 'Titre 1' in french.

15 May 2006 Axel Kiefer

I fully agree with prevoius raters. Andreas work is EXCELLENT. It saved a lot of time.

10 Apr 2007 Jiabei Yuan

If there is a rating over 6, I'll never rate this code with 5!!!

18 Apr 2007 Joseph nonereally

This is a great piece of example code. Thank you Andreas.

27 Aug 2007 E B  
03 Oct 2007 c r

Your code maved me lots of time. Thanks!.

27 Nov 2007 Ramon Planas

Great code!! Thanks very much

01 Dec 2007 Thorbjorn Knudsen

gr8! thx

T

21 Feb 2008 Tobias C

Maybe the most useful script at Matlab central. Well written code with good comments.

03 Apr 2008 B M

only works in english office installations...
so you need to do a lot of hard-coding. On my pc i have a dutch word, my boss an english word .. not easy

25 Apr 2008 Dirk Z

really a good script.
The problem is that the Goto function with wdGoToBookmark as target does not work.
Can anyone help?

27 Aug 2008 Yuval Ben-Dov

Great functionality, easy to follow, thanks for sharing!

10 Sep 2008 Karel Macek

Very usefull.

21 Feb 2009 benharper1977

thank you very much Andreas, your script saves me a lot of time in doing copy&paste with many figures...you're a hero to me.

19 Mar 2009 Andreas Karlsson

In here again checking out what happened during the years. THANKS for all the nice comments!
For Mr. Dirk Z I can say that you should open the file and read the comments. That will give you the hint of doing a search/replace - easy. Read Dimitri Gabris comment from 11 Apr 2006...
After a lot of years as a Matlab/Simulink-programmer I'm now a consultant programming in other languages. Missing the power of Matlab.
If you need help with some Matlab/Simulink coding I would be glad to help...

26 Aug 2009 Santosh  
07 May 2011 Ran

it doesn't work with office 10
this is the error i receive
??? Invoke Error, Dispatch Exception:
Source: Microsoft Word
Description: ???? ??? ????? ???? ????.
Help File: C:\Program Files\Microsoft Office\Office10\1037\wdmain10.chm
Help Context ID: 62e2

Error in ==> WriteToWordFromMatlab>WordText at 198
actx_word_p.Selection.Style = style_p;

Error in ==> WriteToWordFromMatlab at 29
    WordText(ActXWord,TextString,Style,[0,2]);%two enters after text

25 Aug 2011 Todd Brintlinger  
25 Aug 2011 Todd Brintlinger

Sorry about multiple submissions.
Actxserver object had trouble creating files that do not already exist because of trouble/corruption with MAPI32.dll, which is called from Outlook, not Word.? If the file already exists (e.g. TestDoc.doc), it worked no problem.
I have not tried fixing MAPI32.dll, but that may solve problem.

26 Jan 2012 Greg Imamura  
Please login to add a comment or rating.
Updates
15 Feb 2006

Several users wishing more out of the simple script led to new functionality.
- Table with matlab data
- Insertion of symbols
- Table of Contents
- Pagenumbers
- Text in other colors

Also a new section with hints for the eager users.

Tag Activity for this File
Tag Applied By Date/Time
word Cristina McIntire 08 Dec 2008 13:07:34
matlab Cristina McIntire 08 Dec 2008 13:07:34
automatically generate Cristina McIntire 08 Dec 2008 13:07:34
report Cristina McIntire 08 Dec 2008 13:07:34
activex Cristina McIntire 08 Dec 2008 13:07:34
visual basic Cristina McIntire 08 Dec 2008 13:07:34
activex Pedro Moreno Lahore 18 Jul 2011 05:10:03
automatically generate Todd Brintlinger 24 Aug 2011 14:13:24
activex Marco Garieri 18 Nov 2011 03:12:43
automatically generate Marco Garieri 18 Nov 2011 03:12:50

Contact us at files@mathworks.com