Is it possible to convert doc to docx?

Sep 10, 2011 at 6:08 PM

 Hello, I want to convert doc file into docx. Is it possible? And can i count number of words using PHPWORD? Thanks

Oct 22, 2011 at 11:59 PM

Hi - did you try loading the current file as a template (use loadTemplate() ) and then saving it as Word2007?

require_once '../PHPWord.php';

$PHPWord = new PHPWord();

$document = $PHPWord->loadTemplate('Excel2003.doc');

// Save File
$objWriter = PHPWord_IOFactory::createWriter($PHPWord, 'Word2007');
$objWriter->save('Excel2007.docx');

Oct 7, 2013 at 5:57 AM
hi ,
i trying but I have the following problem

( ! ) Warning: ZipArchive::getFromName(): Invalid or unitialized Zip object in C:\wamp\www\doctest\class\PHPWord\Template.php on line 76
Call Stack

Time Memory Function Location

1 0.0020 143864 {main}( ) ..\index2.php:0
2 0.0080 190104 PHPWord->loadTemplate( ) ..\index2.php:5
3 0.0090 200512 PHPWord_Template->__construct( ) ..\PHPWord.php:223
4 0.0210 200984 getFromName ( ) ..\Template.php:76

so it seems here the problem
$this->_documentXML = $this->_objZip->getFromName('word/document.xml');

I'm looking for ('word/document.xml') in phpword folder but it is not here.
some suggestions about, please?
Jan 2, 2014 at 12:55 PM
I have tried cindydolan's answer but all it is doing is creating a blank file.

It is not getting the text from the original .doc file.

Any ideas?

Thanks,
Aug 3, 2014 at 10:12 AM
cindydolan's answer will not work because the loadTemplate uses xml and which is contained in docx file and not doc file.

Cindydolan I suggest you test code before posting it.

Any working ideas?
Aug 8, 2014 at 7:12 AM
Hi i was tried much but it was not working working there was blank docx file created..
Feb 26, 2015 at 9:26 AM
Hi I am also tried but I got empty file only please any one give me idea else provide code.....