Reply
 
Thread Tools Display Modes
  #1   Report Post  
Posted to microsoft.public.word.tables
Dina Dina is offline
external usenet poster
 
Posts: 13
Default formatting tables in a document

Hi,

I would like to know how to use VB editor to select and format all the
tables in a long document. I want to do the following:

Select the tables
Remove all the borders (they are now set to show borders on all sides of
each cell)
Hide all gridlines
Change the default cell margins to 0.00"
Change the column widths - the third column has to be 1" wide, and the
fourth column has to be 5" wide. There are five columns in each table.
Remove the first two and last columns

Is there any way to do this without selecting and changing each table
individually? Is any part of this possible to do?

The other way I can accomplish what I need to do is the following:

Select all the tables
Remove the first two and last column (keeping only the third and fourth
columns)
Convert the tables to text with the following specifications:
The paragraph formatting is set to Hanging by 1"
However, the other text in the document (that did not start out in tables)
will not be formatted this way.

This second way will make the final outcome look the same, so I can do it
this way as well.

Any input will be appreciated!

Thanks!


  #2   Report Post  
Posted to microsoft.public.word.tables
Jay Freedman Jay Freedman is offline
external usenet poster
 
Posts: 9,854
Default formatting tables in a document

On Wed, 24 Dec 2008 16:45:00 -0800, Dina wrote:

Hi,

I would like to know how to use VB editor to select and format all the
tables in a long document. I want to do the following:

Select the tables
Remove all the borders (they are now set to show borders on all sides of
each cell)
Hide all gridlines
Change the default cell margins to 0.00"
Change the column widths - the third column has to be 1" wide, and the
fourth column has to be 5" wide. There are five columns in each table.
Remove the first two and last columns

Is there any way to do this without selecting and changing each table
individually? Is any part of this possible to do?

The other way I can accomplish what I need to do is the following:

Select all the tables
Remove the first two and last column (keeping only the third and fourth
columns)
Convert the tables to text with the following specifications:
The paragraph formatting is set to Hanging by 1"
However, the other text in the document (that did not start out in tables)
will not be formatted this way.

This second way will make the final outcome look the same, so I can do it
this way as well.

Any input will be appreciated!

Thanks!


Hi Dina,

The macro below will do what you asked.

When dealing with objects in a Word document through VBA, it's almost never
necessary to "select" anything. Instead, you refer to an object (such as a Table
object) that represents the thing in the document.

As noted in the comment, turning off the gridlines isn't permanent because it
isn't a property that's saved in the document file. If the document is opened on
another computer where the gridlines option is turned on, the gridlines will
show there.

Sub ReformatTables()
Dim oTbl As Table

' this is effective only for the current session
ActiveDocument.ActiveWindow.View.TableGridlines = False

For Each oTbl In ActiveDocument.Tables
If oTbl.Columns.Count = 5 Then
With oTbl
.Columns(5).Delete
.Columns(2).Delete
.Columns(1).Delete

.Columns(1).Width = InchesToPoints(1)
.Columns(2).Width = InchesToPoints(5)
.LeftPadding = 0
.RightPadding = 0
.Borders.OutsideLineStyle = wdLineStyleNone
.Borders.InsideLineStyle = wdLineStyleNone
End With
Else
MsgBox "Wrong number of columns in " _
& "table on page " & oTbl.Range _
.Information(wdActiveEndAdjustedPageNumber)
End If
Next
End Sub


--
Regards,
Jay Freedman
Microsoft Word MVP FAQ: http://word.mvps.org
Email cannot be acknowledged; please post all follow-ups to the newsgroup so all may benefit.
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
Formatting Tables in Word Mark L[_2_] Microsoft Word Help 1 August 27th 07 11:38 PM
Formatting tables in Word RLHayden Microsoft Word Help 6 October 18th 06 01:11 AM
Formatting tables in a document Sonny1 Tables 4 October 6th 05 06:27 PM
Formatting Tables Bev33 Formatting Long Documents 1 February 7th 05 07:52 AM
Formatting tables Y Chang Formatting Long Documents 3 December 7th 04 02:03 AM


All times are GMT +1. The time now is 11:10 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"