edit docx file using phpword
<p>is it possible to edit existing docx file using phpword?</p>

<p>i want to add footer text to my existing docx file. </p>

<p>there are lot of examples but those examples are creating the doc file from scratch not editing the file
can someone link to me an example? thank you</p>

<p>just like this.</p>

<pre><code>&lt;?php
require_once 'PHPWord.php';
// New Word Document
$PHPWord = new PHPWord();
// New portrait section
$section = $PHPWord-&gt;createSection();
// Add header
$header = $section-&gt;createHeader();
$table = $header-&gt;addTable();
$table-&gt;addRow();
$table-&gt;addCell(4500)-&gt;addText('This is the header.');
$table-&gt;addCell(4500)-&gt;addImage('_earth.jpg', array('width'=&gt;50, 'height'=&gt;50, 'align'=&gt;'right'));
// Add footer
$footer = $section-&gt;createFooter();
$footer-&gt;addPreserveText('Page {PAGE} of {NUMPAGES}.', array('align'=&gt;'center'));
// Write some text
$section-&gt;addTextBreak();
$section-&gt;addText('Some text...');
// Save File
$objWriter = PHPWord_IOFactory::createWriter($PHPWord, 'Word2007');
$objWriter-&gt;save('HeaderFooter.docx');
?&gt;
</code></pre>