Hi all,
I am using VFP 9sp2 to automate the creation of word documents.
I'm creating documents based on groups and locations.
Each Group will have several locations.
Each location will be on a separate page.
each group could have several pages.
I need page breaks when locations change.
The cursor is at the top left of the page and problem is that when I issue the new page break, it is inserted at the top of the document and not at the bottom.
And then when I go to add text on the new page, the text is deleted.
I'm thinking the oRange is incorrect and how do I move the cursor to the bottom of the page so that the insert works and nothing is selected.
Thanks!!!!!!
I am using VFP 9sp2 to automate the creation of word documents.
I'm creating documents based on groups and locations.
Each Group will have several locations.
Each location will be on a separate page.
each group could have several pages.
I need page breaks when locations change.
Code:
oWord = CREATEOBJECT( "Word.Application" )
oWord.Documents.ADD()
oDoc = oWord.ActiveDocument
** Set the margins to be .3"
oDoc.PageSetup.BottomMargin = 21.5
oDoc.PageSetup.LeftMargin = 21.5
oDoc.PageSetup.rightmargin = 21.5
oDoc.PageSetup.topmargin = 21.5
** Set landscape
oDoc.PageSetup.ORIENTATION = 1
** Delete any footer information
oWord.ActiveDocument.Sections( 1 ).Footers.ITEM( 1 ).RANGE.DELETE( 1,1 )
** This is because it is not know who's machine
** will run code and could have custom Normal.dot"
.... get data ....
oRange = oWord.ActiveDocument.RANGE()
xLine = "text to insert"
oRange.InsertAfter( xLine + CRLF )
** Need to insert new page.
oPage.InsertBreak( wdPageBreak )
The cursor is at the top left of the page and problem is that when I issue the new page break, it is inserted at the top of the document and not at the bottom.
And then when I go to add text on the new page, the text is deleted.
I'm thinking the oRange is incorrect and how do I move the cursor to the bottom of the page so that the insert works and nothing is selected.
Thanks!!!!!!