Reply
 
Thread Tools Display Modes
  #1   Report Post  
Posted to microsoft.public.word.tables
evg999
 
Posts: n/a
Default Macros:How to select a specific column of a table and format it using macro?

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

  #2   Report Post  
Posted to microsoft.public.word.tables
Greg
 
Posts: n/a
Default Macros:How to select a specific column of a table and format it using macro?

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

  #3   Report Post  
Posted to microsoft.public.word.tables
evg999
 
Posts: n/a
Default Macros:How to select a specific column of a table and format it using macro?

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

Greg wrote:
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


  #4   Report Post  
Posted to microsoft.public.word.tables
Greg
 
Posts: n/a
Default Macros:How to select a specific column of a table and format it using macro?

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.

Reply
Thread Tools
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
Format and Formula in Table Kelvin Lee Microsoft Word Help 4 January 25th 06 03:33 PM
Format a number column in a table DianePDavies Microsoft Word Help 1 October 6th 05 09:39 AM
Table AutoFormats vs. Table Styles confusion Tony Jollans Tables 5 March 6th 05 08:18 PM
How do I select specific information from an imported table smintey Tables 4 December 7th 04 08:54 PM
Word 2003 Table AutoFormat vs Macro vs VBA Kind writer/user/programmer Tables 1 October 28th 04 03:14 PM


All times are GMT +1. The time now is 02:08 PM.

Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 Microsoft Office Word Forum - WordBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Word"