phpword permission denied for generated docx file

981 views Asked by At

I am working with phpword and there was no problem so far opening the docx files. Suddenly it shows me error messages when I try to open the word files. Here my code

$objWriter = \PhpOffice\PhpWord\IOFactory::createWriter($phpword, 'Word2007');
$filename = 'helloWorld'.date("h:i:s").'.docx';
$objWriter->save($filename);

If i use only 'helloworld.docx', it works. But as soon as I rename the file or add something to 'helloworld' WORD shows me an error-message of not having the permission to open it.

Maybe its because I am using the only readable-version of Word, where I can edit the file. With 'Pages' the files can be opened. The weird thing is, that it worked in the beginning with Microsoft WORD as well.

1

There are 1 answers

0
moody On

Done! I just had to restart Microsoft WORD :)