Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Repeat Row Header

Status
Not open for further replies.

vnk

IS-IT--Management
Nov 14, 2001
33
US
Help me VBA Guru's,

Am kinda new to VBA script and
trying to modify the table properties using a macro.
I want to activate "Repeat row header at the top of each page" and decativate "Allow row across the pages" for all
the tables in the document.

Any help is appreciated.

Thanks,
VNK.
 
Hello vnk,

Sub test()

Dim aTable

For Each aTable In ActiveDocument.Tables
With aTable
.Rows.AllowBreakAcrossPages = False
.Rows(1).HeadingFormat = True
End With
Next aTable

End Sub

So how do you get to this? A good starting point for learning about VBA is to record a macro while you perform all steps in Word. You'll end up with a lot of code and a lot of it will be unnecessary. The recorded code will give you some clues about the names of the objects that you need and their properties. Next step: ask yourself "What objects do I need?" Answer: all Tables. Go to the VBA help and have a look at the help about Tables. Then have a look at the examples. Next check out the properties of a single Table and so on.

Have fun!

ilses
 
Ilses,

Thanks, its cool and pretty neat.

-Vnk.
 
Ilses,

Thanks for the earlier input. I have tried to follow your guidelines to modify the page setup and font for the document but was not able to succeed. I have recorded the macro to modify the page setup for whole document and font size(except for tables) and when I tried to use them in the script it was giving an error.

(e.g)

With ActiveDocument.PageSetup

.LeftMargin = InchesToPoints(1)
.RightMargin = InchesToPoints(1)

End With
 
Hi vnk,

What exactly is going wrong? What error message do you get in which line?

The 4 lines you post do not give an error when I try them as follows:

sub test()
'your code
end sub

ilses
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top