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:
4462 sites
102 fans
Current versions available: 3

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.


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


Screenshot #0


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

Comments RSS


  • 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 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
  • Thu, Dec 22, 2016, 1:21 AM
    I just tested on a clean install using the default Moodle 3.2 XAMPP-based distribution with the "Base" theme, and the "Book administration" menu includes the 3 extra menu items. Note that you have to create the new book, then click "Save and Display", then click on the cogwheel icon to see the Book administration menu. Are you looking for the items in the wrong place? I certainly find the new "Base" theme very confusing.
  • Fri, Apr 7, 2017, 3:26 PM
    Thank you very much for this plugin. I installed it on our test - server running moodle 3.3 . I do have a few questions or requests if you can help us.
    1. when importing a docx file. footnotes are embeded into the text which causes a lot of work.
    2. headings are nor imported (from hebrew) and are stated as index00.htm index001.html ...
    3. when docx numbered, the non-numbered front page is not imported.
    I know that this plugin is good even very good but it could become better with templating & activity set in. (could be as a sub-course) .
    Again thanks for the work
  • Fri, Apr 7, 2017, 10:26 PM
    Hi Avi, thanks for trying out the plugin. Here are some responses.

    1. Footnotes. What would you prefer to happen: a) footnotes are silently deleted; b) footnotes are linked, and placed at the bottom of the page, or c) footnotes are embedded where they occur (in brackets)?

    2. Headings not imported properly. This problem is caused when the default formatting of the heading is overridden. If you select the entire heading, and press +, this removes all overrides, and the heading should then import properly.

    3. First section not imported. I'll take a look at this issue.

    4. Templating and Activity. I don't know what you mean here, can you explain further? (Send me a direct message).

  • Sun, Apr 9, 2017, 4:29 PM
    Thank you for the swift reply , I send in a direct message.
  • Wed, Sep 6, 2017, 12:58 PM
    please!! help me!!! I can't upload file *.docx
  • Wed, Sep 6, 2017, 2:49 PM
    Hi Tran, the facility to upload a file is in the Book administration menu (see screenshot above). If the "Import from Microsoft Word" command is not present, then the plugin is not installed on your server. You can try it out on my test server at too.
  • Thu, Sep 14, 2017, 5:50 PM
    Hello, We have installed the plugin but get an database SQL error as follows:
    Default exception handler: Error writing to database Debug: Incorrect integer value: '/index01.htm' for column 'importsrc' at row 1\nINSERT INTO mdl_book_chapters (bookid,pagenum,importsrc,content,title,contentformat,hidden,timecreated,timemodified,subchapter) VALUES(?,?,?,?,?,?,?,?,?,?)

    What could be the reason?

    We are using Moodle 3.1

    Thanks, in advance for all the help.


  • Thu, Sep 14, 2017, 6:32 PM
    I think the probable reason for this error is that there is a character somewhere in your Word file that is not Unicode-compatible, and therefore the converted HTML cannot be inserted into the MySQL database. "Incorrect integer value: '/index01.htm'" is confusing me though, so it is also possibly related to a formatting problem in one of your "Heading 1"-styled headings. The headings should not have any formatting overrides applied to them. You can remove such overrides by selecting the heading and pressing <Ctrl>+<Space>.
  • Sun, Sep 17, 2017, 6:17 AM
    I continue to have this error:
    "You can not read the file, the file may not exist or there may be problems with the permissions"

    Can I request your help?
    Thank you.
  • Sun, Sep 17, 2017, 10:43 PM
    This could be anything really. Perhaps the file is not in the correct format (.docx), the filename contains forbidden characters, the file contents contains non-Unicode characters, or most likely, your Moodle installation might have temporary folders with incorrect permission settings. Try importing the file on in the "Book Sandbox" course to rule out some of the issues.
Please login to post comments