Macros:How to select a specific column of a table and format it using macro?

E

evg999

Hello,

Please update regarding how to:

I have recorded a macro to convert text to table.
but have problem recording selection of a particular column to format.

I need to select a particular column and modify the formatting.
like resize, change font...

please mail how to do this and steps in vb.

Thanks in advance,
Giri
 
G

Greg

With cursor in applicable table/applicable row, the following would
resize and set a font size value:

Sub FormatTableCol()
Dim oTbl As Table
Dim oCell As Cell
Dim i As Integer
Set oTbl = Selection.Tables(1)
i = Selection.Information(wdStartOfRangeColumnNumber)
oTbl.Columns(i).SetWidth ColumnWidth:=InchesToPoints(0.5),
RulerStyle:=wdAdjustNone
For Each oCell In oTbl.Columns(i).Cells
oCell.Range.Font.Size = 20
Next
End Sub
 
E

evg999

Hi Greg,

Thanks for mailing the macro.
Please check,
On trying to run it,
Compile error: Argument not optional" is displayed.
and <<<.SetWidth>> is highlighted.

Thanks in advance,
Giri
 
G

Greg

Giri,

Works fine here. Note that newgroup readers sometimes changes the line
breaks on long lines.

The lines should read:

i = ...
oTbl.Columns(i) ... RulerStyle:=wdAdjustNone
For Each ..

If breaks have been inserted to change this structure then rearrange
accordingly.
 

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