Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
Home
DiscussionsAccessExcelInfoPathOutlookPowerPointPublisherWord
DirectoryUser Groups
Related Topics
Outlook ExpressInternet ExplorerWindowsMS Server ProductsMore Topics ...

MS Office Forum / Word / Tables / January 2006

Tip: Looking for answers? Try searching our database.

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

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
evg999 - 30 Jan 2006 14:18 GMT
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
Greg - 30 Jan 2006 15:03 GMT
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
evg999 - 31 Jan 2006 05:19 GMT
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

> With cursor in applicable table/applicable row, the following would
> resize and set a font size value:
[quoted text clipped - 11 lines]
> Next
> End Sub
Greg - 31 Jan 2006 11:20 GMT
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.
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.