Table help

F

Fuzzhead

When working with tables how do I get the information from a userform into a
table that I just created? I can’t just say Table(1) because it may not be
the first table in the document. It could be the third or seventh table.
 
M

macropod

Hi Fuzzhead,

You could either:
..bookmark; or
..assign an ID to;
the table, then use that to reference the table.
 
D

Doug Robbins - Word MVP

Declare an object as a Table such as

Dim myTable

then use

Set myTable = ActiveDocument.Tables.Add (etc.)

Then in the rest of your code refer to myTable, e.g.

myTable.Cell(rownum, colnum).Range.Text =

--
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
 
F

Fuzzhead

I did the following but the debuger does not like the when it gets to the
Selection.myTable. How do I add them to my Set myTable line?


Dim myTable
Set myTable = ActiveDocument.Tables.Add(Range:=Selection.Range, NumRows:=3,
NumColumns:= _
1, DefaultTableBehavior:=wdWord9TableBehavior, AutoFitBehavior:= _
wdAutoFitFixed)
Selection.myTable.Rows.SetLeftIndent LeftIndent:=8, RulerStyle:=wdAdjustNone
Selection.myTable.Columns(1).SetWidth ColumnWidth:=432,
RulerStyle:=wdAdjustNone
Selection.myTable.Borders.OutsideLineWidth = wdLineWidth150pt
 
D

Doug Robbins - Word MVP

You do not need to use Selection. Just refer to the table as myTable

--
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
 

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