PDA

View Full Version : how to allign word table columns using vb



chandrakari
05-19-2010, 04:15 AM
hello,
i had generated a word document using vb which contains a table (with 7 columns). every thing ia fine expect right alignment of 6th column. how allign this column. my code is like this


ObjTbl.Columns(6).Select
Selection.ParagraphFormat.Alignment = wdAlignParagraphCenter

can any one help me in this regard

pls note : i am able to align cell by cell by looping no of row. but this process is consumeing more time is i am having more rows

chandra

TonyJollans
05-19-2010, 07:19 AM
Sorry but I don't understand. You want to work on column 6 - what has the number of rows got to do with it?

fumei
05-20-2010, 08:49 AM
Because they are looping through the cells (row by row).

What exactly is your problem?


ObjTbl.Columns(6).Select
Selection.ParagraphFormat.Alignment = wdAlignParagraphCenter
should work.

chandrakari
05-24-2010, 02:43 AM
Hello Tony & fumei, thanks for your interest to solve my issue

my exact problem is like this. i am showing the database table data in a word table which is getting generated dynamically. the table size is no database rows X 7 columns. in this 6th column is showing numeric values. so i want to align this column to right. this i had done by this way


for i=1 to NoRows
ObjTbl.Cells(i,6).Range.ParagraphFormat.Alignment = wdAlignParagrapRight
next i

this is working fine,but consuming more time if NoRows are more. so to avoid time dely i had written like this


ObjTbl.Columns(6).Select
Selection.ParagraphFormat.Alignment = wdAlignParagraphRight

but this code is not excuting as i want. simply it is selcting the 6 column of the table and not aligning it to the right.

what to do?

i am sory for the poor english

TonyJollans
05-24-2010, 04:06 AM
It works for me.

chandrakari
05-24-2010, 09:07 PM
Hello Mr.TonyJollans,
now what i have to do?. only selection is happening no alignment. any sujestions?

TonyJollans
05-25-2010, 01:27 AM
After you've run the code, how are you determining that the paragraphs are not right aligned? Visually, or by checking the formatting in the UI? It is possible that something else is constraining or overriding the setting - difficult to say what. Can you post an example failing document?