P
Piet Linden
Sorry for the lame subject... Anyway... on to the problem!
I am working on some code that is executing from within Access.
I am trying to insert a chunk of text (which works fine) and then
after each chunk, insert a continuous section break. The section
breaks get inserted, but they're all mysteriously at the top of the
document instead of between the sections of text! What am I doing
wrong?
Here's the code... (don't laugh, I'm most definitely not a good Word
programmer!)
Private Sub OpenQueries()
<SNIP>
' Open a new document to dump data into... change to a template if
necessary
objWordApp.Documents.Add
Set objWordDoc = objWordApp.ActiveDocument
'---THE SECTION BREAK INSERTS WORK, BUT THEY APPEAR AT THE TOP OF THE
DOCUMENT INSTEAD OF BETWEEN THE CHUNKS OF TEXT.... .Content
or .Range does the same thing... what gives?
If varItem = "PopulationSize" Then
'FAILS
varData = rstAny.GetString()
.Range.InsertAfter "Population," & varData
.Range.InsertParagraphAfter
'
.Content.InsertBreak Type:=wdSectionBreakContinuous
Else
varData = rstAny.GetString()
.Range.InsertAfter varData
.Range.InsertParagraphAfter
.Content.InsertBreak Type:=wdSectionBreakContinuous
End If
End With
rstAny.Close
Next varItem
Okay, so what's the proper way to Insert a section break after each
inserted chunk of text?
The GetString stuff is returning a delimited chunk of text that writes
just fine into Word... I just can't get the section breaks to insert
in the right place. They all mysteriously end up at the top of the
document! What gives?
Thanks!
Pieter
I am working on some code that is executing from within Access.
I am trying to insert a chunk of text (which works fine) and then
after each chunk, insert a continuous section break. The section
breaks get inserted, but they're all mysteriously at the top of the
document instead of between the sections of text! What am I doing
wrong?
Here's the code... (don't laugh, I'm most definitely not a good Word
programmer!)
Private Sub OpenQueries()
<SNIP>
' Open a new document to dump data into... change to a template if
necessary
objWordApp.Documents.Add
Set objWordDoc = objWordApp.ActiveDocument
'---THE SECTION BREAK INSERTS WORK, BUT THEY APPEAR AT THE TOP OF THE
DOCUMENT INSTEAD OF BETWEEN THE CHUNKS OF TEXT.... .Content
or .Range does the same thing... what gives?
If varItem = "PopulationSize" Then
'FAILS
varData = rstAny.GetString()
.Range.InsertAfter "Population," & varData
.Range.InsertParagraphAfter
'
.Content.InsertBreak Type:=wdSectionBreakContinuous
Else
varData = rstAny.GetString()
.Range.InsertAfter varData
.Range.InsertParagraphAfter
.Content.InsertBreak Type:=wdSectionBreakContinuous
End If
End With
rstAny.Close
Next varItem
Okay, so what's the proper way to Insert a section break after each
inserted chunk of text?
The GetString stuff is returning a delimited chunk of text that writes
just fine into Word... I just can't get the section breaks to insert
in the right place. They all mysteriously end up at the top of the
document! What gives?
Thanks!
Pieter