Microsoft Word File Import/Export (Book)

Book tools ::: booktool_wordimport
Maintained by Eoin Campbell
Import the contents of a Microsoft Word file into a book, splitting it into chapters and (optionally) subchapters, based on the heading styles. The file can be saved from Microsoft Word, Google Docs or LibreOffice, as long as it has a '.docx' suffix. Also supports exporting books to Word format, for round-trip editing.
Latest release:
6077 sites
1k downloads
105 fans
Current versions available: 2

This plugin supports importing a Microsoft Word docx-formatted file as chapters to a book. The file is split into chapters and subchapters based on the built-in heading styles "Heading 1" and "Heading 2" in Word. Embedded images are also imported if they are in web-compatible format (GIF, PNG, JPEG).

It imports .docx files only, not the older .doc format.  Note that files in.docm format (i.e. including macros) are not supported.

Both GoogleDocs and LibreOffice 5.x can also save files in .docx format, and they will import too, but generally the quality is not as good as those files saved from the native Word editor, even if the document uses the same built-in "Heading 1" and "Heading 2" styles well. Your mileage may vary.

Note also that the PHP XSL extension must be enabled on your webserver, and the plugin requires Moodle 2.7 or higher.

After installation, the Book administration menu should have a new item added, similar to the screenshot below. You must create a new book, or turn on editing in an existing book, to see this menu.

Book administration menu

The plugin can also be used to export books, or chapters from books, back into Word .doc format. In general heading elements in HTML are converted back into corresponding heading styles in Word, and so on with other styles. The exported file must be opened first using Microsoft Word. You can then save it to .docx format and edit it in LibreOffice or GoogleDocs. If the exported file contains images, then you must use Word 2019 or higher, or Word 365 (web version) , in order for images to be opened correctly.

Sets

This plugin is part of set Microsoft Word file import/export.

Screenshots

Screenshot #0

Contributors

Eoin Campbell (Lead maintainer)
Please login to view contributors details and/or to contact them

Comments RSS

Comments

  • Fri, Jan 8, 2016, 1:05 AM
    Hi Eoin. Like David, I initially tried using a docx file with subheadings made by Libre Office which failed. I got two debug messages about Pass 1 and Pass 2 being successful, above a page showing the document content, but with no Continue or save or any other type of button to finish the import with.

    I then tried using a MS Word 2007 docx copy of the same file. It failed with the same two debug messages and then had additional info, "Can not read file, either file does not exist or there are permission problems
    More information about this error", followed by some more debug info,a stack trace, and a Continue button. Clicking continue takes me back to the Moodle front page, and upon checking, the book is still empty.

    Since I can't put pictures of the debug output here, let me know if you would like me to, and I will try to add them at the github source page.
  • Fri, Jan 8, 2016, 1:33 AM
    Upon playing with my Libre Office docx file some more, not getting a Continue button at all seems to have been because the document I was using had a title formatted as a title. Once I changed it to Heading 1, I started getting the document content into the book, even though I still did not see a continue button. The text was ALL in Italics, also.

    I saved the text as txt, then opened it in MS Word. I then formatted H1 and H2 as needed and saved as docx. I was then able to successfully import the file. With debugging on I still get some debug information about pass 1 and pass 2, but I also now get the Importing and Relinking message followed by a continue button. The book looks as it should.

    I have not tried this with any pictures yet.
  • Fri, Jan 8, 2016, 4:46 AM
    Hi AL, many thanks for trying it out. I think the problem is that the .docx file saved by Libre Office does not contain heading styles with the same name as Word itself uses (e.g. Heading 1, Heading 2, etc.), so the import process doesn't recognise any chapters at all, and imports nothing. I have now changed the behaviour so that the whole file is treated as a single chapter if no top-level headings (with the right name, i.e. "Heading 1") are present. I just released version 0.9.2 with this fix.
  • Hakan Gür
    Mon, Jan 11, 2016, 8:10 PM
    Using MS Office 2007 and Moodle 2.9.3, I converted an office file without images into a book with this plugin and it worked smoothly. Yet, when I added an image to the same office document and transferred it into another blank book, the image on the first page was not transferred and the heading title is now "index01_00.htm" where it should have been "Testing 1". Still, I believe the plugin is really useful (the images can be added afterwards).
  • Mon, Jan 11, 2016, 10:39 PM
    Hi Hakan,
    Thanks for trying it out.
    The most likely reason for this problem is that the image is placed before the first "Heading 1"
    style in the document.

    The converter only includes content after Heading 1 styles.
    Since the heading title is not included as the page name, it is also likely
    that there is no Heading 1 style in the document at all, which would also
    prevent any content from being imported.
  • Hakan Gür
    Tue, Jan 12, 2016, 1:31 AM
    Hello again,

    You are right; the image was placed right before the first "Heading 1". I corrected this and now the images are transferred together with the page. As far as this issue is concerned, I can confirm that this is not a bug. smile

    Thank you very much for your efforts.

    Best regards.
  • Thu, Feb 4, 2016, 10:17 PM
    Thank you for the Word import plugin.
    I think we would be using it a lot.
    I installed the Microsoft Word file import plugin, but the system looks exactly the same as before installation.
    I don't see an icon or a button in Moodle to import Word documents.
    Where can I find info about this?
    Do we need to restart the server or something?
    I am a newbie in Moodle world, so please tell me step by step, what should I need to make it work.
    Thanks,
    Marco
  • Fri, Feb 5, 2016, 2:58 AM
    I have added a bit to the description to make this a bit clearer. The Book Administration menu has a new item added "Import chapters from Microsoft Word file"
  • Thu, Mar 17, 2016, 3:31 PM
    Dear Eoin, thank you for forking Lucimoo ebook import and export and creating this new plugin - excellent! smile
    Please give correct attribution / credit for Lucimoo to Mikael Ylikoski - http://lucidor.org/lucimoo/ on your page https://github.com/ecampbell/moodle-booktool_wordimport
  • Wed, Jul 6, 2016, 3:36 PM
    Hello.
    Congratulations for this plugin, it's exactly what I need !
    I'm using Office 2013, french version.
    I encouter some little problems maybe you can solve. In a first document :
    - When a paragraph content a Word link (Référence/Renvoi), in moodle, the paragraph appear as an html link form the Word link to the end of the paragraph
    - If a paragraps content a bloc of text (Insert/Forms/Text bloc), it means the header is not correctly interpreted (appear for example as index09_06_sub.htm)
    - The "puces" (I dont't know the english term...) are not converted (ul/ol in HTML).
    In an another Word doc, none of the headers are interpreted, but styles are Heading1, heading2

    You can contact me (pascal.gagnebin@ceff.ch) if you want I send you the Word files.
    Best regards,
    Pascal
  • Thu, Aug 25, 2016, 4:10 AM
    Hello. This plugin correctly work into Moodle 3.1?
  • Thu, Aug 25, 2016, 4:16 AM
    Yes, it does, and I've updated the version information to reflect this.
  • Tue, Nov 1, 2016, 6:21 PM
    Hi. I'm using the plugin but one page of the Book is only one image (A4) and when i export to word the page is blanck. Is this ok?
  • Thu, Nov 3, 2016, 5:05 AM
    Hi Dinis,
    The exported Word file needs some post-processing if the book contains images. You need to download a Word template from http://www.moodle2word.net/ that contains a macro that processes the Word file, converting the images into embedded images in Word.
    Unfortunately, this macro has recently begun to be considered by Microsoft Windows Defender to be a virus, so you may have difficulty downloading it. You would need to turn off Defender, download the template, run it on the Word file, and then turn Defender on again, in order to get the images.
    Unless you have a lot of images, it's probably easier to re-insert the image manually.
    Sorry I can't be of more assistance.
  • Wed, Dec 21, 2016, 11:58 PM
    I just tried the lateset version in a new install of Moodle 3.2 as well as an upgraded site and although the Word Import works great in drag and drop mode in Atto, the 3 added menu items in the Book administration menu are missing.
    I tried an exsiting Book as well as a new Book and no luck.

    Am I missing something?
    > Running under PHP 7.0
    >
Please login to post comments