How center horizontally text in a cell ?

M

MoiMeme

Hi,

how can I programmatically horizontally center the text in a table row /
cells ?

TIA
 
G

Gordon Bentley-Mix

Set the Alignment property of the ParagraphFormat property of the Range of
the selected cell to wdAlignParagraphCenter. For example:

ActiveDocument.Tables(1).Range.Cells(1).Range.ParagraphFormat.Alignment=wdAlignParagraphCenter

horizontally centres the text in the first cell of the first table in the
active document.
--
Cheers!
Gordon

Uninvited email contact will be marked as SPAM and ignored. Please post all
follow-ups to the newsgroup.
 
G

Gordon Bentley-Mix

BTW, if you want to centre the text in an entire row, just substitute 'Rows'
for 'Cells' - something like this:

ActiveDocument.Tables(1).Range.Rows(2).Range.ParagraphFormat.Alignment =
wdAlignParagraphCenter

which centres the text in every cell in the second row of the first table in
the active document.
--
Cheers!
Gordon

Uninvited email contact will be marked as SPAM and ignored. Please post all
follow-ups to the newsgroup.
 
J

Jay Freedman

Hi,

how can I programmatically horizontally center the text in a table row /
cells ?

TIA

Leaving it up to you to choose the right table and row...

With ActiveDocument.Tables(1).Rows(2)
.Range.Paragraphs.Alignment = wdAlignParagraphCenter
End With
 

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