Update table cell in footer !

G

Grenier

looking for the right syntax to access a cell in a footer ?

here's what I've tried with no success...
Set Rng = ActiveDocument.Sections(1).Footers(wdHeaderFooterPrimary).Range
with rng.table(1).cell(2,2)
.text = "updated on february 25"
end with

Merci !
 
L

Lene Fredborg

Replace the line:
With rng.table(1).cell(2,2)

with this line:
With rng.Tables(1).Cell(2, 2).Range

--
Regards
Lene Fredborg
DocTools - Denmark
www.thedoctools.com
Document automation - add-ins, macros and templates for Microsoft Word
 
D

Doug Robbins - Word MVP

A cell does not have a .Text attribute. It is the .Text attribute for the
..Range of the cell that you must use.

ActiveDocument.Sections(1).Footers(wdHeaderFooterPrimary).Range.Tables(1).Cell(2,2).Range.Text
= "updated on february 25"

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

Grenier

tried it both way and still does not work ...

ActiveDocument.Sections(1).Footers(wdHeaderFooterPrimary).Range.Tables(1).Cell(2,2).Range.Text = "updated on february 25"

Set rng = ActiveDocument.Sections(1).Footers(wdHeaderFooterPrimary).Range
With rng.Tables(1).Cell(1, 1).Range
.Text = "updated on february 25"
End With

any guess ?
 
L

Lene Fredborg

Are you sure the footer that contains the table is a wdHeaderFooterPrimary?
For example, if you have set a different first page and the table is in the
footer of the first page, it is a wdHeaderFooterFirstPage.

--
Regards
Lene Fredborg
DocTools - Denmark
www.thedoctools.com
Document automation - add-ins, macros and templates for Microsoft Word
 
G

Grenier

Manage to get it working with the following syntax.

Dim rng As Range
Dim TblFooter As Table

Set TblFooter =
ActiveDocument.Sections(3).Footers(wdHeaderFooterFirstPage).Range.Tables(1)
Set Rng = TblFooter.Cell(1, 1).Range
Rng.Text = "Updated on ......"

Found out that the syntax you gave me only worked with a document created by
hand. My original document is created by Access via automation... can't
figure out the difference but you pointed me in the right direction. Thank's !
 
D

Doug Robbins - Word MVP

Obviously the table into which you wanted to insert the data was in Section
3, not Section 1.

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