Replace REPTTMPL.Template With FileToStr(cFileName)This would be much cleaner. However, the point is that you are putting the whole RTF content into the memo file and then using the VisDocs LoadTemplate method, right?
*1. Create a temporary file name and write the RTF data in REPTTMPL.Template out to a disk file. m.cTempFile = forceExt(Substr(Sys(2015),3), 'RTF') =StrToFile(REPTTMPL.Template, m.cTempFile) *2. Open the tempfile as follows using the loadTemplateFile method (not the loadTemplate method) m.nStream = m.oRtf.loadTemplateFile(m.cTempFile)Obviously, you need to delete the temporary file you have created after it has been loaded into your application.