#include word2000.h Set Step On *--------------------- Local oPages, nPageCount lcfile1="c:\TEMP\L80UJ5P5.RTF" oWord = Createobject("word.application") oWord.Documents.Open(lcfile1) * Represents the browser tool used to move the insertion point to * objects in a document. We are browsing "Pages" on this occasion. m.oword.Application.Browser.Target = wdBrowsePage * Get a reference to the pages object. m.oPages = oWord.Activedocument.BuiltInDocumentProperties(wdPropertyPages) * Record the page object's value property (the number of pages). m.nPageCount = m.oPages.Value * Iterate through the pages in the document. For m.nKount = 1 To m.nPageCount * Get a range on the "current" page. We can do this using the * in-built "\page" bookmark. oRange = oWord.Activedocument.bookmarks("\page").Range() * If we are on the one before last page, we have to delete * the application added page break. If m.nKount = m.nPageCount - 1 oRange.Collapse(wdCollapseEnd) oRange.Select() oWord.Selection.typebackspace() && Lone space. oWord.Selection.typebackspace() && PageBreak. oWord.Selection.InsertBreak(wdSectionBreakNextPage) Else oRange.Collapse(wdCollapseEnd) oRange.InsertBreak(iif(m.nKount==m.nPageCount, wdSectionBreakNextPage, wdSectionBreakContinuous)) Endif m.oWord.Application.Browser.Next() Endfor lcfile2="c:\TEMP\L80UJ5RX.RTF" oRange.InsertFile(lcfile2,"", .F.,.F.,.F.) oWord.Visible=.T. oWord.Quit(wdDoNotSaveChanges)