Automation of word in Access 2007

  • Thread starter Thread starter KSH
  • Start date Start date
K

KSH

I am trying to do some simple code to create a word document from Excel when
I try to break and start another page the text on the first page disappears:
Below is a simple example, the first page prints if I take out the insert
break, but if I put it in I get a blank 1st page and "started New" on the
second. Must be missing something obvious and can't find good documentation
for the properties here.

With rngCurrent
.InsertAfter RS!FullName
.InsertAfter vbCrLf
.InsertAfter RS!Address
.InsertAfter vbCrLf
'''new page
.InsertBreak wdPageBreak

.InsertAfter "started new"

End With

'
 
Hi

You need to 'collapse' the range otherwise the pagebreak replaces everything
that came before it.

So, change your coding to:

.InsertAfter vbCrLf
.Collapse Direction:=wdCollapseEnd
.InsertBreak wdPageBreak

If this doesn't work try wdCollapseStart

Cheers.

BW
 
Thanks, that worked!
--
KSH


BeWyched said:
Hi

You need to 'collapse' the range otherwise the pagebreak replaces everything
that came before it.

So, change your coding to:

.InsertAfter vbCrLf
.Collapse Direction:=wdCollapseEnd
.InsertBreak wdPageBreak

If this doesn't work try wdCollapseStart

Cheers.

BW
 
Back
Top