Create table macro using a loop

T

Tom

I'd like to create a table macro using a loop. The columns are fixed. There
are 7 columns but the number of rows are dynamic. The number of rows will be
determined by a bookmark. Can this be done?

I cannot use a catalog merge. It's a long story.

Thanks
Tom
 
G

Greg Maxey

Tom,

Not sure what "create a table macro using a loop" means. Do you want to
create a table with a macro with the row number determined by a bookmark
value? Maybe something like:

Sub MakeTable()
Dim i As Integer
i = ActiveDocument.Bookmarks("Rows").Range.Text

ActiveDocument.Tables.Add Selection.Range, i, 7, _
DefaultTableBehavior:=wdWord9TableBehavior, _
AutoFitBehavior:=wdAutoFitFixed
End Sub
 
J

Jezebel

Why use a loop? If you know the number of rows and columns, just create the
table as needed --

Activedocument.Tables.Add Range:=Selection.Range, NumRows:=[RowCount],
NumColumns:=[ColCount]
 
T

Tom

Yes that's what I'm looking for. Instead of using bookmarks in the macro.
Could I reference a mail merge field called rows. If yes, How would the
script change? Also I'm using 2000 Word. In the script it references 1997
word. Does that make a difference.

Thanks again.
 

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