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:
8352 sites
2k downloads
121 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.

Screenshots

Screenshot #0

Contributors

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

Comments RSS

Show comments
  • Eoin Campbell
    lun, 12 ago 2024, 11:56 PM
    Hi Claus, I am unable to access the file at the URL you provide. It is possible that you need to change the permissions to allow anyone access it.
  • Eoin Campbell
    mar, 13 ago 2024, 12:13 AM
    Hi Claus, you could try opening the generated file in Word, copying all the generated text, and pasting it into a new blank Word file. Then try importing the new file. If this works, then it indicates that the Word file generated directly from Python has some internal issue preventing it from being imported into a Book using the plugin. Your Python script should probably use explicit headings rather than bold-formatted text, which the plugin prefers, e.g. doc.add_heading('Heading level 1', 1)
  • Soporte Mi Portafolio Digital
    mar, 24 sept 2024, 9:17 PM
    Good day, Eoin. I am having issues with the plugin when importing/exporting. I am using Moodle 4, and the plugin version is 1.4.12 (Build: 2023021700).

    When exporting the book, some images are broken, and it doesn't maintain the layout. The document only shows part of the content.

    When importing, the tables lose their formatting. How can I solve these issues?
  • Eoin Campbell
    mié, 25 sept 2024, 12:18 AM
    If the book content was originally created internally in Moodle, it is possible that the images were not inserted directly into the Book chapter content, but included by reference instead, i.e. using a hard link to the image, which is stored elsewhere. This would explain why the image isn't displaying on export. You don't explicitly mention what table formatting is lost, but one likely issue is that visible cell borders in Word are not retained. The best workaround for this issue is to add some extra CSS to your sites' theme (in Site administration > Appearance > Themes > Adaptable > Settings) to specify how borders are displayed.
  • Soporte Mi Portafolio Digital
    vie, 27 sept 2024, 8:59 PM
    Thank you, Eoin. On another note, in the books I’m working on, it only exports partially. I have embedded a video that I took from the social network X, and everything shows up fine until that point. However, from the video onwards, nothing is exported. I’m using the
  • Eoin Campbell
    vie, 27 sept 2024, 9:43 PM
    Embedded videos are not supported. I think you should create a link to the video instead.
  • Marina M
    mar, 7 ene 2025, 10:22 PM
    Hello! When importing, the bullet points get messed up and the text appears incomplete. Any solution? Thank you!
  • Eoin Campbell
    mié, 8 ene 2025, 1:11 AM
    The conversion process maps named styles in Word into corresponding elements in HTML, but a bullet point in Word usually doesn't use the specific named style "List Bullet": instead it uses the generic "Normal" style, or possibly "List Paragraph". You must therefore manually set the style of bullet points to "List Bullet". An easy way to do this is to add a shortcut key for the "List Bullet" style, for example <Ctrl>+<Shift>+L, <Ctrl>+<Shift>+8, or just <Ctrl>+8. Then when you want to start a bullet list, type the shortcut key. See "How to Assign Keyboard Shortcuts to Microsoft Word Heading Styles" at https://www.msofficemaestro.com/blog/how-to-assign-keyboard-shortcuts-to-microsoft-word-heading-styles
  • Eoin Campbell
    mié, 8 ene 2025, 1:30 AM
    I'm not sure exactly what you mean by "the text appears incomplete". One possibility is that paragraphs are out-dented too much, and the first few letters of each line are therefore hidden from view.
  • Marina M
    vie, 10 ene 2025, 2:16 AM
    Yes, I think that's exactly it. Thank you, Eoin
  • Geoff Cole
    mié, 23 abr 2025, 5:11 PM
    Hi, I've just run a git update from the wordimport master repository, but when I try to upgrade the database I get an error that
    version 2025041501 requires version 2025041400 of Moodle which fails and 2025041400 of booktool_importhtml which fails and is not available
    I am running version 4.4.8+ of Moodle.
    How can I correct these dependencies?
    Thanks
    Geoff
  • Eoin Campbell
    mié, 23 abr 2025, 10:20 PM
    Hi Geoff, I've released a new version on Git, v1.4.14, which requires only Moodle 3.9.
  • Geoff Cole
    mié, 23 abr 2025, 11:31 PM
    Eoin, Thanks for that, that's fixed that plugin... However I'm seeing the same for question/format/wordtable, local/glossary_wordtable, local/lesson_wordimport and local/wordimport. I think these are yours as well?
    Sorry!
  • Eoin Campbell
    mié, 23 abr 2025, 11:44 PM
    Hi Geoff, I have now fixed local/glossary_wordimport (v1.1.7). However, Moodle 5.0 requires an incompatible code change in question/format/wordtable, so the latest Github release (tagged v3.9.6) is for Moodle 5.0 only. You need to download v3.9.5 instead. local/lesson_wordimport relies on question/format/wordtable, so you need to download the older version from Github. local/wordimport is also updated for 5.0 to include tiny_wordimport instead of atto_wordimport (Atto has been dropped from 5.0), so again you need older version.
  • Geoff Cole
    jue, 24 abr 2025, 12:15 AM
    Thanks Eoin, I have now set the the tags to the required version and updated glossary_wordimport and everything looks good!
1 2 3 4 5 6 7
Please login to post comments