diff --git a/src/PhpWord/TemplateProcessor.php b/src/PhpWord/TemplateProcessor.php index fa8d8e65..821f5cbd 100644 --- a/src/PhpWord/TemplateProcessor.php +++ b/src/PhpWord/TemplateProcessor.php @@ -278,6 +278,11 @@ class TemplateProcessor $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');