Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

horizontal alignment of an individual cell ???

2,935 views
Skip to first unread message

John Parker

unread,
Mar 26, 2002, 4:05:28 PM3/26/02
to
I'm creating a table from VBA and I has 2 columns how the first column needs
to be left aligned and the second column needs to right aligned. How do I
set the horizontal alignment of an individual cell? I found how to the
entire row but need to do an indivual cell.

thank
john

Mark Baird

unread,
Mar 27, 2002, 1:09:15 AM3/27/02
to
You have to set the horizontal alignment of the paragraph in the cell.

Selection.ParagraphFormat.Alignment = wdAlignParagraphRight

Mark Baird
"John Parker" <john....@blackwell.com> wrote in message
news:eDBsMnQ1BHA.2228@tkmsftngp07...

John Parker

unread,
Mar 27, 2002, 12:55:04 PM3/27/02
to
How do I set the selection to the individual cell? I've just added it .

"Mark Baird" <mbai...@hotmail.com> wrote in message
news:u9POiXV1BHA.1372@tkmsftngp02...

Mark Baird

unread,
Mar 27, 2002, 9:14:22 PM3/27/02
to
You do not need to use the selection object. You can use the range object.

There are multiple options available.

----------------------------------------------------------------------------
------------------
You can select the cell.

ActiveDocument.Tables(1).Cell(2, 4).Select

----------------------------------------------------------------------------
------------------
If you already know what cell it is you may as well use the Range object.

' Current table cursor is in and the cell in row two column 4.
Selection.Tables(1).Cell(2, 4).Range.ParagraphFormat.Alignment =
wdAlignParagraphRight

' Second table in the document.
ActiveDocument.Tables(2).Cell(2, 3).Range.ParagraphFormat.Alignment =
wdAlignParagraphRight

----------------------------------------------------------------------------
------------------
Set the alignment in every cell in every table in the document..

Dim wrdCell As Cell
Dim wrdTable As Table

' Move through each table and each cell in those tables.
For Each wrdTable In ActiveDocument.Tables
For Each wrdCell In wrdTable.Range.Cells
wrdCell.Range.ParagraphFormat.Alignment = wdAlignParagraphRight
Next wrdCell
Next wrdTable

Mark Baird
"John Parker" <john....@blackwell.com> wrote in message

news:#5yLAhb1BHA.1960@tkmsftngp03...

0 new messages