tables and bookmarks

B

Bruce Baker

H

I have a vb program inserting a couple of tables into a word document - there are bookmark place-holder

The first table is inserted fine. Then there is a paragraph following in my document (already in the document) and then the second bookmark for the second table

The problem is that the second table is overwriting the first - it is not moving to the second bookmark in the document to insert the second table...

It definitely finds the second bookmark ok

Any ideas ? THanks

my code looks lik

Resume15
On Error GoTo ErrHandler16
.activeDocument.Bookmarks("saleAcceptList").Select ' this is the first bookmar
insertSaleAcceptList person.personID, objW

Resume16
On Error GoTo ErrHandler17
.activeDocument.Bookmarks("saleRejectList").Select ' this is the second bookmar
insertSaleRejectList person.personID, objWd
 
P

Peter Hewett

Hi ?

Try posting the code in the insertSaleAcceptList and insertSaleRejectList
procedures because that's where you're doing the insertion.

HTH + Cheers - ???
 
B

Bruce Baker

insertSaleEntryList calls the following procedure - I've just kept the first few line

Hope this is enough..

thank
Bruc

Private Sub insertSaleHorseList(rs As ADODB.Recordset, objWd As Word.Application
Dim ctr As Intege
Dim wrdSelection As Word.Selectio

Set wrdSelection = objWd.Selectio

' Insert a new table with # bookings + 1 for the heade
objWd.activeDocument.Tables.Add wrdSelection.Range, NumRows:=rs.RecordCount + 1, NumColumns:=
 
P

Peter Hewett

Hi Bruce

The code looks fine. It should work as expected as long as the two bookmarks
are in separate paragraphs.

The fact that it's VB/COM is pretty irrelevant, but I'd do some testing with
your document from within Word using VBA. It's just easier to debug. Just
port the parts of your code that select the bookmarks and then insert the
tables and step through the code, toggle backwards and forwards between Word
and the VBA IDE to see exactly where the insertion point is. If all that
works well then it's something else causing the problem.

Try that and let me know how you get on.

BTW what version of Word are you using???

HTH + Cheers - Peter
 
B

Bruce Baker

Thanks for your help Pete

I was being particularly stupid - I was referencing table 1 each tim

e.g. With objWd.activeDocument.Tables(1
' Set the column width
.Columns(1).SetWidth 50, wdAdjustNon
.Columns(2).SetWidth 120, wdAdjustNon
.Columns(3).SetWidth 120, wdAdjustNon

thank
Bruce
 

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