Reply
 
Thread Tools Display Modes
  #1   Report Post  
Posted to microsoft.public.word.vba.general,microsoft.public.word.vba.beginners,microsoft.public.word.tables
Nathan Franklin
 
Posts: n/a
Default inserting tables

Hello List,

I have been trying to work this for a while now, i can;t seem to get it
working...

I am using word automation to insert tables into my document from a bookmark
range. The problem is when I loop to isnert a table each table will insert
into the first row and column of the previous table.

Here is my code below

For I = 1 to 20
InteriorRange = Doc.Bookmarks.Item("InteriorBuilding").Range ' range obj

InteriorRange.InsertParagraphAfter()

RoomTable = Doc.Tables.Add(InteriorRange, 3, 2) ' doc a reference to the
current document

RoomTable.Cell(1, 1).Range.InsertAfter("tst item")
RoomTable.Cell(1, 2).Range.InsertAfter("test")
RoomTable.Cell(2, 1).Range.InsertAfter("test")
RoomTable.Cell(2,2).Range.InsertAfter("test")
RoomTable.Cell(3, 1).Range.InsertAfter("test")
RoomTable.Cell(3, 2).Range.InsertAfter("test")

RoomTable.Cell(1, 1).Merge(RoomTable.Cell(1, 2))

Next

Any help would be greatly appreciated



thanks very much

nathan


  #2   Report Post  
Posted to microsoft.public.word.vba.general,microsoft.public.word.vba.beginners,microsoft.public.word.tables
Doug Robbins - Word MVP
 
Posts: n/a
Default inserting tables

You are inserting all of the tables into the one bookmark. You need to have
20 bookmarks, or some other way of defining where it is that you want the
tables inserted.

If you are doing this at the end of the document,

You could use

Dim myrange as Range, Dim RoomTable as Table
For i = 1 to 20
Doc.Range.InsertAfter vbCr
Set myrange = Doc.Range
myrange.Start=myrange.End
Set RoomTable = Doc.Tables.Add(myrange, 3, 2)
etc.
--
Hope this helps.

Please reply to the newsgroup unless you wish to avail yourself of my
services on a paid consulting basis.

Doug Robbins - Word MVP

"Nathan Franklin" wrote in message
...
Hello List,

I have been trying to work this for a while now, i can;t seem to get it
working...

I am using word automation to insert tables into my document from a
bookmark range. The problem is when I loop to isnert a table each table
will insert into the first row and column of the previous table.

Here is my code below

For I = 1 to 20
InteriorRange = Doc.Bookmarks.Item("InteriorBuilding").Range ' range ob

InteriorRange.InsertParagraphAfter()

RoomTable = Doc.Tables.Add(InteriorRange, 3, 2) ' doc a reference to the
current document

RoomTable.Cell(1, 1).Range.InsertAfter("tst item")
RoomTable.Cell(1, 2).Range.InsertAfter("test")
RoomTable.Cell(2, 1).Range.InsertAfter("test")
RoomTable.Cell(2,2).Range.InsertAfter("test")
RoomTable.Cell(3, 1).Range.InsertAfter("test")
RoomTable.Cell(3, 2).Range.InsertAfter("test")

RoomTable.Cell(1, 1).Merge(RoomTable.Cell(1, 2))

Next

Any help would be greatly appreciated



thanks very much

nathan




Reply
Thread Tools
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
Inserting Excel tables into Word Louise Microsoft Word Help 13 November 1st 05 06:56 PM
Inserting Tables from Excel in a picture frame in Word. Jørund Tables 1 October 25th 05 08:19 PM
Problems inserting tables Connie L Microsoft Word Help 0 October 12th 05 12:35 AM
Inserting Pictures from Files in Tables ohjeanie Tables 2 September 2nd 05 06:14 PM
Word 2003 replaces list of tables when inserting list of figures kburns New Users 1 May 24th 05 11:00 PM


All times are GMT +1. The time now is 09:46 PM.

Copyright ©2000 - 2023, Jelsoft Enterprises Ltd.
Copyright 2004-2023 Microsoft Office Word Forum - WordBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Word"