diff --git a/docx/__init__.py b/docx/__init__.py index 33e15e31a..8828bb375 100644 --- a/docx/__init__.py +++ b/docx/__init__.py @@ -33,6 +33,8 @@ def part_class_selector(content_type, reltype): PartFactory.part_type_for[CT.WML_NUMBERING] = NumberingPart PartFactory.part_type_for[CT.WML_SETTINGS] = SettingsPart PartFactory.part_type_for[CT.WML_STYLES] = StylesPart +PartFactory.part_type_for[CT.WML_DOCUMENT_MACRO_ENABLED_MAIN] = DocumentPart + del ( CT, diff --git a/docx/api.py b/docx/api.py index 9a2215d7a..f42f050a8 100644 --- a/docx/api.py +++ b/docx/api.py @@ -23,7 +23,7 @@ def Document(docx=None): """ docx = _default_docx_path() if docx is None else docx document_part = Package.open(docx).main_document_part - if document_part.content_type != CT.WML_DOCUMENT_MAIN: + if document_part.content_type not in [CT.WML_DOCUMENT_MAIN, CT.WML_DOCUMENT_MACRO_ENABLED_MAIN]: tmpl = "file '%s' is not a Word file, content type is '%s'" raise ValueError(tmpl % (docx, document_part.content_type)) return document_part.document diff --git a/docx/opc/constants.py b/docx/opc/constants.py index b90aa394a..b1bbcc521 100644 --- a/docx/opc/constants.py +++ b/docx/opc/constants.py @@ -280,6 +280,7 @@ class CONTENT_TYPE(object): 'application/vnd.openxmlformats-officedocument.wordprocessingml.docu' 'ment.main+xml' ) + WML_DOCUMENT_MACRO_ENABLED_MAIN = ( 'application/vnd.ms-word.document.macroEnabled.main+xml' ) WML_ENDNOTES = ( 'application/vnd.openxmlformats-officedocument.wordprocessingml.endn' 'otes+xml'