Home |
Search |
Today's Posts |
#1
Posted to microsoft.public.word.tables
|
|||
|
|||
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
Posted to microsoft.public.word.tables
|
|||
|
|||
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 | |
|
|
Similar Threads | ||||
Thread | Forum | |||
Formatting Tables in Word | Microsoft Word Help | |||
Formatting tables in Word | Microsoft Word Help | |||
Formatting tables in a document | Tables | |||
Formatting Tables | Formatting Long Documents | |||
Formatting tables | Formatting Long Documents |