Quantcast
Channel: VBForums - Visual Basic 6 and Earlier
Viewing all articles
Browse latest Browse all 21843

Finding End of Word Doc Pages

$
0
0
I am starting off my VB6 code with the following in order to create a Word Document:

Code:

Dim WordApp As Word.Application
Dim WordDoc As Word.Document
Set WordApp = New Word.Application
Set WordDoc = WordApp.Documents.Add(DocumentType:=wdNewBlankDocument)

From there, I add several names and addresses from my Access DB, filling up many pages of information, using vblf's to advance lines.

As each name and address 'set' contains between 3 and 7 lines (variable because of amount of data available), I get some name/address sets split between two pages. I would like to be able to code it so that when I get to within a 'certain distance' from the bottom of each page, I advance to the next page, so that I don't have split name/address sets.

I would include my code, but it is pretty extensive as there are SEVERAL checks I have to make of the data before writing it to a line (like missing streets, nicknames, spouses yes/no, children, etc, etc etc). But essentially, a dumbed down version might go like this: (After I have retrieved the data from the DB)

Code:

(looping through my recordset (rs) until end......
WordApp.Selection.TypeText rs!lastname
WordApp.Selection.TypeText vblf
WordApp.Selection.TypeText rs!firstname
WordApp.Selection.TypeText vblf
WordApp.Selection.TypeText rs!spouse    'IF EXISTS
WordApp.Selection.TypeText vblf
WordApp.Selection.TypeText rs!street
WordApp.Selection.TypeText vblf
WordApp.Selection.TypeText rs!city
REM  Then end it with a double line feed
WordApp.Selection.TypeText vblf
WordApp.Selection.TypeText vblf
rs.movenext

Any suggestions would be greatly appreciated.

Viewing all articles
Browse latest Browse all 21843

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>