enter text in cell in word table

S

swhiting

I have a Word template that contains 1 table.

I have successfully updated other information in the template with
automation from Access.

I have not been able to automate filling in the existing table with data
though.

Can you please give an example of how to enter text intoa cell of an
existing table?

Thanks.
 
J

Jean-Guy Marcil

swhiting was telling us:
swhiting nous racontait que :
I have a Word template that contains 1 table.

I have successfully updated other information in the template with
automation from Access.

I have not been able to automate filling in the existing table with
data though.

Can you please give an example of how to enter text intoa cell of an
existing table?

Here is sample code to get you going:

'_______________________________________
Dim tblTarget As Table

Set tblTarget = ActiveDocument.Tables(1)

With tblTarget
.Cell(1, 1).Range.Text = "First row, first column"
.Cell(1, 2).Range.Text = "First row, second column"
.Cell(2, 1).Range.Text = "Second row, first column"
.Cell(2, 2).Range.Text = "Second row, second column"

End With
'_______________________________________

--

Salut!
_______________________________________
Jean-Guy Marcil - Word MVP
(e-mail address removed)
Word MVP site: http://www.word.mvps.org
 
S

swhiting

I have an error at: "Set tblTarget = ActiveDocument.Tables(1)"

Is there something I need to do in Word to identify the table?
I don't understand what (1) refers to in the set command.

Thanks for your help!
 
S

swhiting

I get an error message at: Set tblTarget = ActiveDocument.Tables(1)

Is there something I need to do in Word to identify the table?
I do not understand what (1) refers to in the Set command.

Thanks for your help.
 
S

swhiting

I guess it pays to re-boot regularly when you're developing this stuff......

With ActiveDocument.Tables(1)
.Cell(Row:=1, Column:=1).Range.InsertAfter Text:="test"
End With


Did not work before I rebooted, but did after.

Jean, thanks for your input.
 

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