Automation of word in Access 2007

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

'
 
B

BeWyched

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
 
K

KSH

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
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top