set cell to left alignment with other right

C

Chris

I am using automation from access to word template with code as follows
which works fine

With m_docReport.Tables(1)
With .Rows.Last
.Range.Rows.Alignment = wdAlignRowRight
.Borders.InsideLineStyle = wdLineStyleNone
.Cells(1).Range.Text = sBldgName
.Cells(2).Range.Text = sFloor
.Cells(3).Range.Text = Format(sProductNo, "!>@@@-@@@@-@@@")
.Cells(4).Range.Text = FormatCurrency(curPrice, 2)
.Cells(5).Range.Text = iQty
.Cells(6).Range.Text = FormatCurrency(curExtPrice, 2)
End With

I would like Cell (3) to be left aligned and others to be right aligned. But
can't see how to do it.

Thanks
Chris
 
J

Jay Freedman

Hi, Chris,

First, the .Rows.Alignment setting doesn't do what you think it does. It
aligns the *row* against the right page margin, but it doesn't change the
alignement of the text inside the cells. Instead, you want the
..ParagraphFormat.Alignment.

With that change, and separately aligning the ParagraphFormat of Cell(3),
you get what you expected:

With .Rows.Last
'.Range.Rows.Alignment = wdAlignRowRight
.Range.ParagraphFormat.Alignment = wdAlignParagraphRight
.Cells(3).Range.ParagraphFormat.Alignment = wdAlignParagraphLeft
 

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