Error found in paragraph 1 at tab "<<TR>>" Not a valid RTF file - no header foundSo I used an RTF file for the report that I’m having the most problems with and I’m loading it directly into the data stream using your suggested code. It didn’t change the behavior but your suggestions have drastically increased the pace of my debugging sequence. I’m getting nowhere much faster now. Seriously, I do appreciate not having to take so much time for each re-try. It has also eliminated the possibility of the problem dealing with copying the RTF file into the memo field or getting the template out of the memo field and into the data stream. It must be in my code or in the template.
LOCAL cLastCategory, cLastItem, category, iz, oProgress, THERMCT m.cLastCategory = '' m.cLastItem = '' m.category = '' SELECT Offallco3 COUNT ALL TO THERMCT m.oProgress = THISFORM.oMessage.ProgressBar('Processing ' + ALLTRIM(Offallco3.Fullname)) m.oProgress.SetProgressRange(1,THERMCT) m.iz = 1 GO TOP DO WHILE ! EOF() category = ALLTRIM(Offallco3.Fullname) * Make a new copy of the entire detail group when the category * changes, except for the very first time. IF ! EMPTY(m.cLastCategory) AND (! m.cLastCategory == category) m.ortf.CopyGroup(m.nStream, 'Category', 'Item') * Copying the entire group will also create a new item row, since * the item row is in the range of tags specified in CopyGroup(). ENDIF * Insert text for the new category when the category changes IF ! m.cLastCategory == category m.cLastCategory = category m.ortf.InsertText(m.nStream, 'Category', CHR(13) + TRIM(category)) ENDIF SCAN WHILE ALLTRIM(m.cLastCategory) = ALLTRIM(Offallco3.Fullname) IF ortf.IsDirty(m.nStream, 'Item') ortf.Copyrow(m.nStream, 'Item') ENDIF m.oProgress.UpdateProgress(m.iz) m.oProgress.SetProgressMessage('Processing ' + ALLTRIM(category)) m.iz = m.iz + 1 temp = ALLTRIM(Offallco3.Orgname) **m.ortf.InsertText(m.nstream, 'xx', '- ') && MOVES data in base table TO STREAM m.ortf.InsertText(m.nstream, 'Item', temp) && MOVES data in base table TO STREAM IF Offallco3.Chair = .T. m.ortf.InsertText(m.nstream, 'CH', 'X') && MOVES data in base table TO STREAM ENDIF IF Offallco3.Dir = .T. m.ortf.InsertText(m.nstream, 'DI', 'X') && ENDIF IF Offallco3.Pres = .T. m.ortf.InsertText(m.nstream, 'PR', 'X') && ENDIF IF Offallco3.Vicepres = .T. m.ortf.InsertText(m.nstream, 'VP', 'X') && ENDIF IF Offallco3.Sec = .T. m.ortf.InsertText(m.nstream, 'SC', 'X') && ENDIF IF Offallco3.Tres = .T. m.ortf.InsertText(m.nstream, 'TR', 'X') && ENDIF ENDSCAN SELECT Offallco3 ENDDO m.oProgress.CloseProgress()>>I save the template using MS Word in an RTF file then open the file using Windows Notepad. I copy the content from the Notepad and paste it into a memo field.
>Replace REPTTMPL.Template With FileToStr(cFileName) >>
>*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) >>