M
Marco Boeijen
Hello,
I have the following problem.
I made a template in Word containing bookmarks. From my Access VBA
code I can point to those bookmarks and add data there using a Range
object. So far so good.
Now I'm trying to copy tables at the end of my Range object using a
For Next loop. The tables are based on the first table that's already
there. Here's my problem. When in the same loop I try to put data in
the table It's using the first table instead of the newly added table.
It seems like the tables are added after the Range object instead of
before the end of the Range opbject.
Here's my code:
Set oRange = oDoc.Bookmarks(strBookMarkName).Range
oDoc.Range.Tables(1).Range.Copy
For intCounter = 1 To 10
oRange.Paste
oRange.Tables(intCounter).Rows(1).Cells(2).Range.InsertAfter
"Text"
Next intCounter
When intCounter reaches 2 it gives an error message saying the
requested member of the collection does not exist. If I ask for
oRange.Tables.Count it says 1 and not 2. So the newly added table
isn't part of the Range object.
Can anyone help me out here?
Kind regards,
Marco Boeijen
I have the following problem.
I made a template in Word containing bookmarks. From my Access VBA
code I can point to those bookmarks and add data there using a Range
object. So far so good.
Now I'm trying to copy tables at the end of my Range object using a
For Next loop. The tables are based on the first table that's already
there. Here's my problem. When in the same loop I try to put data in
the table It's using the first table instead of the newly added table.
It seems like the tables are added after the Range object instead of
before the end of the Range opbject.
Here's my code:
Set oRange = oDoc.Bookmarks(strBookMarkName).Range
oDoc.Range.Tables(1).Range.Copy
For intCounter = 1 To 10
oRange.Paste
oRange.Tables(intCounter).Rows(1).Cells(2).Range.InsertAfter
"Text"
Next intCounter
When intCounter reaches 2 it gives an error message saying the
requested member of the collection does not exist. If I ask for
oRange.Tables.Count it says 1 and not 2. So the newly added table
isn't part of the Range object.
Can anyone help me out here?
Kind regards,
Marco Boeijen