formatting tables in word document

D

DD

I want to format all the tables in my document for consistency.

I would like all the cells' text to have left-centre alignment
I would like the first row and the left column to contain bold text.
I also would like the first row, as a header row, to be underlined.

Any help would be appreciated.

Regards
D Dawson
 
J

Jean-Guy Marcil

DD was telling us:
DD nous racontait que :
I want to format all the tables in my document for consistency.

I would like all the cells' text to have left-centre alignment

What do you mean by "left-centre"?
I would like the first row and the left column to contain bold text.

Are there any merged cells in those tables?
I also would like the first row, as a header row, to be underlined.

Are you sure? Bold underlined text in a table cell? Personally, I think the
underlining is overkill and a little bit on the ugly side (unless there are
no cell borders).


--
Salut!
_______________________________________
Jean-Guy Marcil - Word MVP
(e-mail address removed)
Word MVP site: http://www.word.mvps.org
 
D

DD

Jean-Guy Marcil In response to your questions
What do you mean by "left-centre"?

The best way I can explain this is left (vertical) and centre (horizontal)
for all cells. Manually I can select this alignment from the right click
menu.
Are there any merged cells in those tables?

There are no merged cells
Are you sure? Bold underlined text in a table cell? Personally, I think
the underlining is overkill and a little bit on the ugly side (unless
there are no cell borders).

There are no cell borders or other lines in the table, just a line below the
header row

Regards
D Dawson
 
H

Helmut Weber

Hi DD,

something along these lines.

Sub TestCC()
Dim oTbl As Table
Dim oCll As Cell
For Each oTbl In ActiveDocument.Tables
oTbl.Range.Cells.VerticalAlignment = wdCellAlignVerticalCenter
oTbl.Range.ParagraphFormat.Alignment = wdAlignParagraphLeft
oTbl.Rows(1).Range.Font.Bold = True
oTbl.Rows(1).Range.Font.Underline = wdUnderlineSingle
For Each oCll In oTbl.Columns(1).Cells
oCll.Range.Font.Bold = True
Next
Next
End Sub

Though I agree with Jean-Guy's opinion
about bold plus underlined.

Might be appropriate for a sentence of death. ;-)

--
Greetings from Bavaria, Germany

Helmut Weber, MVP WordVBA

Win XP, Office 2003
"red.sys" & Chr$(64) & "t-online.de"
 
D

DD

Thanks Helmut

This is a very good macro code.

I totally agree with you, that bold and underlined is overkill, but that is
not what I meant.

What I'm really looking for is for the firt row to have a border line below
it. The table is to have no borders, or vertical/ horizontal dividing lines,
except a line to show that the first row is the header row.

i.e.

BoldHeader1 BoldHeader2 BoldHeader3
-----------underline---------------------------
BoldText Text Text

BoldText Text Text
etc
( I Hope this displays properly to clarify my example )

Can you alter the code to include a border line below the first row, then I
will be able to use it.

The tables are included in four documents which make up a report we issue to
a client. You will understand how I need some control over consistency.
These four word documents make up one report and I have various people
working on each document at different times.

Greetings from Glasgow, Scotland
D Dawson
 
D

Doug Robbins - Word MVP

The following will apply a border to the bottom of the first row of the
first table in the document:

With ActiveDocument.Tables(1).Rows(1).Borders(wdBorderBottom)
.LineStyle = wdLineStyleSingle
.Color = wdColorBlack
End With


--
Hope this helps.

Please reply to the newsgroup unless you wish to avail yourself of my
services on a paid consulting basis.

Doug Robbins - Word MVP
 
D

DD

Thanks you all for your help

FYI:

My final macro looks like this:

Sub fmtTables()
Dim oTbl As Table
Dim oCll As Cell
For Each oTbl In ActiveDocument.Tables
oTbl.Range.Cells.VerticalAlignment = wdCellAlignVerticalCenter
oTbl.Range.ParagraphFormat.Alignment = wdAlignParagraphLeft
oTbl.Range.ParagraphFormat.SpaceBefore = 3
oTbl.Range.ParagraphFormat.SpaceBeforeAuto = False
oTbl.Range.ParagraphFormat.SpaceAfter = 3
oTbl.Range.ParagraphFormat.SpaceAfterAuto = False
oTbl.Range.ParagraphFormat.LineSpacingRule = wdLineSpaceSingle
oTbl.Rows(1).Range.Font.Bold = True
oTbl.Rows(1).Range.Font.Underline = wdUnderlineNone
oTbl.Rows(1).Borders(wdBorderBottom).LineStyle = wdLineStyleSingle
oTbl.Rows(1).Borders(wdBorderBottom).Color = wdColorBlack
For Each oCll In oTbl.Columns(1).Cells
oCll.Range.Font.Bold = True
Next
Next
End Sub
 

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