diff --git a/docs/api/enum/WdBuiltinStyle.rst b/docs/api/enum/WdBuiltinStyle.rst index b7aa682d4..49f10d48c 100644 --- a/docs/api/enum/WdBuiltinStyle.rst +++ b/docs/api/enum/WdBuiltinStyle.rst @@ -10,11 +10,14 @@ Specifies a built-in Microsoft Word style. Example:: from docx import Document - from docx.enum.style import WD_STYLE document = Document() styles = document.styles - style = styles[WD_STYLE.BODY_TEXT] + style = styles["Body Text"] + +A built-in style must be defined in the document before it can be looked up. +Style lookup uses the style's English UI name, e.g. ``"Body Text"``; a +``WD_STYLE`` member like ``WD_STYLE.BODY_TEXT`` is not a style lookup key. ---- diff --git a/src/docx/enum/style.py b/src/docx/enum/style.py index d2474611d..44885d930 100644 --- a/src/docx/enum/style.py +++ b/src/docx/enum/style.py @@ -11,12 +11,15 @@ class WD_BUILTIN_STYLE(BaseEnum): Example:: from docx import Document - from docx.enum.style import WD_STYLE document = Document() styles = document.styles - style = styles[WD_STYLE.BODY_TEXT] + style = styles["Body Text"] + A built-in style must be defined in the document before it can be looked + up. Style lookup uses the style's English UI name, e.g. ``"Body Text"``; + a ``WD_STYLE`` member like ``WD_STYLE.BODY_TEXT`` is not a style lookup + key. MS API name: `WdBuiltinStyle`