diff --git a/src/PhpWord/TemplateProcessor.php b/src/PhpWord/TemplateProcessor.php index 7efc0f1ac8..18ec6ec42b 100644 --- a/src/PhpWord/TemplateProcessor.php +++ b/src/PhpWord/TemplateProcessor.php @@ -274,6 +274,11 @@ public function setComplexValue($search, \PhpOffice\PhpWord\Element\AbstractElem $elementWriter->write(); $where = $this->findContainingXmlBlockForMacro($search, 'w:r'); + + if ($where === false) { + return; + } + $block = $this->getSlice($where['start'], $where['end']); $textParts = $this->splitTextIntoTexts($block); $this->replaceXmlBlock($search, $textParts, 'w:r');