Reading core_properties using python-docx
<p>I'm trying to read the last_saved_by attribute on docx files. I've followed the comments on Github, and from <a href="http://stackoverflow.com/questions/22625022/reading-coreproperties-keywords-from-docx-file-with-python-docx">this question</a>. It seems that support has been added, but the documentation isn't very clear for me. </p>

<p>I've entered the following code into my script (Notepad++):</p>

<pre><code>import docx

document = Document()
core_properties = document.core_properties
core_properties.author = 'Foo B. Baz'
document.save('new-filename.docx')
</code></pre>

<p>I only get an error message at the end:</p>

<pre><code>NameError: name 'Document' is not defined
</code></pre>

<p>I'm not sure where I'm going wrong. :(</p>

<p>When I enter it line by line through python itself, the problem seems to come up from the second line.</p>

<p>I'm using Python 3.4, and docx 0.8.6</p>

<p>If the only thing you need from the <code>docx</code> module is <code>Document</code>, then you only need to use</p>

<pre><code>from docx import Document
</code></pre>

<p>If you use more than that, you could use</p>

<pre><code>import docx
document = docx.Document()
</code></pre>

<p>importing specific names from the <code>docx</code> module is your choice; either way, you don't <em>need</em> to have two lines importing from (or importing) <code>docx</code>, although it's not expensive to have both.</p>

python python-3.x word-2010 python-docx