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 Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Word Table 1

Status
Not open for further replies.

JackSkellington

Technical User
Jul 28, 2005
86
GB
I'm looking to set the repeat as header row at the top of each page programmatically can this be done, and how would I go about doing it?

Alternatively could I catch the new page and write the headings again?
 

JackSkellington, you can use the following piece of code to get your work done.

For this sample you should have a table present in your document with atleast 7 rows. To see the effect, span your rows to multiple pages by entering large amount of data.
Code:
   ' To make 1st row of 1st table in ActiveDocument a header row.
   ActiveDocument.Tables(1).Rows(1).HeadingFormat = True

   ' To make 2nd, 5th and 7th rows of 1st table in ActiveDocument header rows and to reset 1st row of 1st table in ActiveDocument a normal row.
   ActiveDocument.Tables(1).Rows(2).HeadingFormat = True
   ActiveDocument.Tables(1).Rows(5).HeadingFormat = True
   ActiveDocument.Tables(1).Rows(7).HeadingFormat = True

   ActiveDocument.Tables(1).Rows(1).HeadingFormat = False

However I assume

- that you have included Word Object Library reference in your project.
- that you are familiar with Word Interop Assemblies and Word Object Model.
- that you are using .NET 2.0 (Visual Basic 2005)

If you want to get help on Word Object Model and Office Interop Assemblies to automate Office objects (Word objects, Excel Object, Outlook objects) refer to MSDN library. You can search and find a lot of information how to automate Word in your application.

>> Alternatively could I catch the new page and write the headings again?
By using the above line of code, you need not to use your alternative.
 
Unfortunately I’m not using .Net 2.0. The table is currently formatted using objTable and oDocument commands
 
JackSkellington,

You can do the same thing in .NET 1.x. The only difference is the reference of Word Object Library. You will set the reference to Word Object Library from COM tab in Project References dialog box. And all Word Object heirarchy will be exposed to you.

Hope it helps.

 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top