Help with Macro

J

Janet A. Thompson

I give up. I thought I know how to do this but don't. I have 100 docs with
a table in both the header and body. I need to select a blockt of the body
table, the part that has visible borders around it. I need to change the
format to normal character spacing and a font of Arial 10.
I need to set the table properties to cell options .01 top, .01 bottom, .08
either side.
I need to set the para. spacing to Exactly 12 pt. with no before or after
spacing.

How to do? for the fastest way? Thanks in advance!
 
D

Doug Robbins - Word MVP

Tell us more about the block of the table. Is the fact that the cells in it
have borders the only thing that distinguishes it from the balance of the
table? Is the block of table in each of the documents comprised of the same
cells in terms of row numbers/column numbers?

The following code would apply the desired formatting to the first cell of
the first table in the document:

Dim myrange As Range
Set myrange = ActiveDocument.Tables(1).Cell(1, 1).Range
With myrange
With .ParagraphFormat
.SpaceAfter = 0
.SpaceBefore = 0
.LineSpacing = 12
End With
With .Font
.Name = "Arial"
.Size = 12
End With
With .Cells(1)
.BottomPadding = InchesToPoints(0.01)
.TopPadding = InchesToPoints(0.01)
.LeftPadding = InchesToPoints(0.08)
.RightPadding = InchesToPoints(0.08)
End With
End With

To do this sort of thing with 100 documents, you could modify the code in
the article "Find & ReplaceAll on a batch of documents in the same folderâ€
at:

http://www.word.mvps.org/FAQs/MacrosVBA/BatchFR.htm

so that it incorporated the above code (modified to deal with the required
range of cells)
--
Hope this helps.

Please reply to the newsgroup unless you wish to avail yourself of my
services on a paid consulting basis.

Doug Robbins - Word MVP, originally posted via msnews.microsoft.com
 
J

Janet A. Thompson

thanks!
Each doc has a table that looks the same:
First 2 rows have borders and have various merged cells and text is
right-justified
Next 9 rows are 2 columns that have text that is left-justified
There is some text that is bolded in various cells

but the spacing and font characteristics I've listed above would be the same
for the whole table.
Table has line thickness of 0.5 inch
 
J

Janet A. Thompson

There are a total of 32 cells in this table.
Row 1 has 6 columns
Row 2 has 8 columns
Rows 3-11 have 2 columns

How would the code be modified?
 
J

Janet A. Thompson

The table has all borders visible. I need all table cells to have Arial font,
size 10, with normal character spacing. I need all table cells to have the
"padding" .01 top and bottom and .08 both sides.
Row 1 and Row 2 have multiple columns with right-justified text.
Row 3 to Row 9 have 2 columns and left-justified text. There are various
bolded text in these rows and what exists now I would want to remain bolded.
Does this help? Thank you!

I don't how to code this?
Janet A.
 
D

Doug Robbins - Word MVP

So if it is the whole of the table to which you want to apply that
formatting use:

Dim myrange As Range
With ActiveDocument.Tables(1)
Set myrange = .Range
With myrange
With .ParagraphFormat
.SpaceAfter = 0
.SpaceBefore = 0
.LineSpacing = 12
End With
With .Font
.Name = "Arial"
.Size = 12
End With
End With
.BottomPadding = InchesToPoints(0.01)
.TopPadding = InchesToPoints(0.01)
.LeftPadding = InchesToPoints(0.08)
.RightPadding = InchesToPoints(0.08)
End With

The above code will affect emboldened text in any of the rows.

--
Hope this helps

Doug Robbins - Word MVP
Please reply only to the newsgroups unless you wish to avail yourself of my
services on a paid, professional basis.
 

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