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 / December 2006

Tip: Looking for answers? Try searching our database.

macro that repeats header rows of all tables?

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
Tom - 15 Dec 2006 13:59 GMT
Does anyone know how to make a macro that repeats the header row of
tables that span multiple pages? This is done by selecting the table
and going to Table > Heading Rows repeat. If I have a document with 20
tables, I would like to automate this via a macro, but I'm not sure how.
Doug Robbins - Word MVP - 15 Dec 2006 14:11 GMT
The following macro will do it:

Sub MakeHeadingRows()
Dim i As Long
With ActiveDocument
   For i = 1 To .Tables.Count
       .Tables(i).Rows(1).HeadingFormat = True
   Next i
End With
End Sub

Signature

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

> Does anyone know how to make a macro that repeats the header row of
> tables that span multiple pages? This is done by selecting the table
> and going to Table > Heading Rows repeat. If I have a document with 20
> tables, I would like to automate this via a macro, but I'm not sure how.
satya.mahesh@gmail.com - 19 Dec 2006 21:29 GMT
Thanks for the macro code. I did try the code and it worked well for
tables which did not have any merged cells. For tables with merged
cells it gave an error. How do we take care of such validations here?

My document has lot of tables and I want to repeat the table headers as
the tables span across pages and it is difficult to read. Some tables
have merged cells as well.

Can a macro handle these scenarios and repeat table headers for valid
tables only?

> The following macro will do it:
>
[quoted text clipped - 19 lines]
> > and going to Table > Heading Rows repeat. If I have a document with 20
> > tables, I would like to automate this via a macro, but I'm not sure how.
Doug Robbins - Word MVP - 20 Dec 2006 09:06 GMT
The following won't be as quick, but will overcome that problem

Sub MakeHeadingRows()
Dim i As Long
With ActiveDocument
   For i = 1 To .Tables.Count
       .Tables(i).Cell(1, 1).Select
       Selection.Rows.HeadingFormat = True
   Next i
End With
End Sub

Signature

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

> Thanks for the macro code. I did try the code and it worked well for
> tables which did not have any merged cells. For tables with merged
[quoted text clipped - 31 lines]
>> > tables, I would like to automate this via a macro, but I'm not sure
>> > how.
Stefan Blom - 15 Dec 2006 14:14 GMT
Use the HeadingFormat property (defined for Row objects). For example,
to set the first row of all tables in the active document to be
heading rows, use a macro such as the following:

Sub test()
  Dim t As Table
  For Each t In ActiveDocument.Tables
     t.Rows(1).HeadingFormat = True
  Next t
End Sub

Signature

Stefan Blom
Microsoft Word MVP

> Does anyone know how to make a macro that repeats the header row of
> tables that span multiple pages? This is done by selecting the table
> and going to Table > Heading Rows repeat. If I have a document with 20
> tables, I would like to automate this via a macro, but I'm not sure how.
Tom - 15 Dec 2006 15:05 GMT
Thanks! The macro worked perfectly. I also wanted to indent the tables,
so I added another parameter in there from a different macro.

Sub Fixmytables()
  Dim t As Table
  For Each t In ActiveDocument.Tables
     t.Rows(1).HeadingFormat = True
     t.Rows.LeftIndent = CentimetersToPoints(2.9)
  Next t
End Sub

Can you tell me where I would find all the parameters that I can apply
for tables? Thanks for your help.
Tom - 15 Dec 2006 15:05 GMT
Thanks! The macro worked perfectly. I also wanted to indent the tables,
so I added another parameter in there from a different macro.

Sub Fixmytables()
  Dim t As Table
  For Each t In ActiveDocument.Tables
     t.Rows(1).HeadingFormat = True
     t.Rows.LeftIndent = CentimetersToPoints(2.9)
  Next t
End Sub

Can you tell me where I would find all the parameters that I can apply
for tables? Thanks for your help.
Tom - 15 Dec 2006 15:05 GMT
Thanks! The macro worked perfectly. I also wanted to indent the tables,
so I added another parameter in there from a different macro.

Sub Fixmytables()
  Dim t As Table
  For Each t In ActiveDocument.Tables
     t.Rows(1).HeadingFormat = True
     t.Rows.LeftIndent = CentimetersToPoints(2.9)
  Next t
End Sub

Can you tell me where I would find all the parameters that I can apply
for tables? Thanks for your help.
Tom - 15 Dec 2006 15:06 GMT
Thanks! The macro worked perfectly. I also wanted to indent the tables,
so I added another parameter in there from a different macro.

Sub Fixmytables()
  Dim t As Table
  For Each t In ActiveDocument.Tables
     t.Rows(1).HeadingFormat = True
     t.Rows.LeftIndent = CentimetersToPoints(2.9)
  Next t
End Sub

Can you tell me where I would find all the parameters that I can apply
for tables? Thanks for your help
Stefan Blom - 15 Dec 2006 15:16 GMT
Read about the Table object in Word VBA Help. Or use the Object
Browser (press F2 with the Visual Basic Editor displayed). There you
can view objects, their properties and methods, and use F1 to display
help on specific items.

Signature

Stefan Blom
Microsoft Word MVP

> Thanks! The macro worked perfectly. I also wanted to indent the tables,
> so I added another parameter in there from a different macro.
[quoted text clipped - 9 lines]
> Can you tell me where I would find all the parameters that I can apply
> for tables? Thanks for your help
 
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.