Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

How do I align text in a table column.

Status
Not open for further replies.

spruceni

Technical User
May 18, 2007
72
GB
Hi
Moved this from another forum as I was told this was a better home for this query. Apology for cross posting.

Hi as a newbie I am trying to build a table from a recordset in Access.

So I have the table
ActiveDocument.Tables.Add Range:=Selection.Range, NumRows:=varNumRec, NumColumns:=5

I have the font
With ActiveDocument.Tables(1).Rows(1).Range.Font
.Name = "Arial"
.Size = 12
.Bold = True
End With

and I have the text in the column ( there are 5 columns)
Selection.Tables(1).Cell(1, 4).Range.Text = "Days Outstanding"

I just can not find the code to center the text in any or all of the columns. I have searched the internet but it seems very difficult to find an answer.

Please help.
 
I think you may use a Style to achieve your goal.

Hope This Helps, PH.
FAQ219-2884
FAQ181-2886
 
Thanks
This is where I show my lack of knowledge :)

I looked up style in the VBA Access help and it did not seem to indicate that I could set the alignment.

e.g.
You can use the Style property to specify or determine the appearance of tabs on a tab control.

Tabs 0 (Default) Tabs appear as tabs.
Buttons 1 Tabs appear as buttons.
None 2 No tabs appear in the control

Regards
 
I meant a Word style.

Hope This Helps, PH.
FAQ219-2884
FAQ181-2886
 

Are you saying that the alignment can not be set from inside VBA?

 
Sure it can.
Code:
ActiveDocument.Tables(1).Cell(1, 3).Range _
   .ParagraphFormat.Alignment = wdAlignParagraphCenter
will center the text in Cell(1,3) of Tables(1).


Gerry
My paintings and sculpture
 
Thank you for all your help

I now have a workable solution

 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top