Skip to content

Reading and Writing to an Existing Docx File (No template) #991

@ghost

Description

I'm trying to make some changes to the text of an existing docx file (simple text replacement for now).

When I save the file, there is no error given, all seems to work. But when I then go ahead and open the file in Word, I get the following error message:

The Open XML file bla.docx cannot be opened because there are problems with the contents or the file name may contain invalid characters (for example, \/).

No error detail available

line 2

Now, I did simplify my code, making no changes at all to the document, just reading it, and then writing it, and I still get that error. So it's not because of something new I added;

$doc = \PhpOffice\PhpWord\IOFactory::load('bla.docx');
$objWriter = \PhpOffice\PhpWord\IOFactory::createWriter($doc, 'Word2007');
$objWriter->save('bla-write.docx');

Any idea what's going on here and how to fix it?


Want to back this issue? Post a bounty on it! We accept bounties via Bountysource.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions