[OfficeUtils] Problem with Word2013

[OfficeUtils] Problem with Word2013

  
Forge Component
(17)
Published on 26 Apr by Elena Novozhilova
17 votes
Published on 26 Apr by Elena Novozhilova

Hi,

It seems that replacing placeholders with their actual values (Word_Export_SetText) doesn't work when the template is created from scratch using Word2013. Please find the attached example of a not working template. If I create such a template by downloading the template from your OfficeSample module (WordExportTemplateNet.docx; it is surely created with some older version of Word because my Word opens it in the Compatibility Mode)), deleting all its content and putting (all the time using Word2013) the same content as in "Not working.docx"- it works perfectly.

I've checked it with 2.2.6 version for OS 9 and 3.0.0. version for OS 10.

[Update] Further investigation has shown that I can prepare a working template using even Word2013 - but all placeholders MUST NOT be typed in but pasted from Notepad.

Regards

Tomasz

Solution

 Hi Tomasz,
 
The problem that you are  facing is not related with the Word version. The word document representation is made up of paragraphs and runs under them. Text in the document is stored under the run on xml representation.
 
When writing the template, if you do operations to the text like deleting parts or stopping typing and then  resume, the text will be spitted in several runs. Since OfficeUtills will be searching for a run that contains all the text, it will not be able to find the text to be replaced.
 
So I recommend you to delete the placeholders on your template an rewrite them again with no stops, or write them in notepad and copy them to the word template.

Best regards,

Elena

Solution

Hi,

thanks for such a quick reply. 

Well, this makes it not so user friendly. But OK, now I know what is the basis.

Regards

Tomasz