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 / Programming / July 2007

Tip: Looking for answers? Try searching our database.

VBA, Heading Rows Repeat & Multiple Heading Rows

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
Thomas - 18 Jun 2007 11:44 GMT
Hello,
I've got some tables in a document and I'm checking (with VBA) for these
tables if they have "Heading Rows Repeat" for their first row.  The problem
is : if I have a multiple heading rows with some cells merged, VBA tell me
this : "Cannot access individual rows in this collection because the table
has vertically merged cells".

Here is the code used :
   For Each myTable In ActiveDocument.Tables
       myTable.Rows(1).Select
       If Not Selection.Rows.HeadingFormat = wdToggle Then
          addVerifyWarning "Heading Rows Repeat must be set in tables'
first row.", myTable.Range.Paragraphs(1)
       End If
   Next

Is there a problem with this code ?
Helmut Weber - 30 Jun 2007 08:03 GMT
Hi Thomas,

I don't know what "addVerifyWarning" is.

For checking for headers and circumventing
the error you get, you may try:

Sub Test459()
Dim mytable As Table
For Each mytable In ActiveDocument.Tables
  mytable.Range.Cells(1).Select
  If Not Selection.Rows.HeadingFormat = wdToggle Then
     MsgBox "Warning"
  End If
Next
End Sub

Signature

Greetings from Bavaria, Germany

Helmut Weber, MVP WordVBA

Win XP, Office 2003
"red.sys" & Chr$(64) & "t-online.de"

Klaus Linke - 04 Jul 2007 20:04 GMT
> Here is the code used :
>    For Each myTable In ActiveDocument.Tables
[quoted text clipped - 6 lines]
>
> Is there a problem with this code ?

Hi Thomas,

Helmut has addressed your immediate problem.

But there's another problem with your code that you should take care of.

You probably want to use
If Selection.Rows.HeadingFormat = wdFalse Then

You can use
Selection.Rows.HeadingFormat = wdToggle
by itself to toggle the state (turn heading rows into normal rows, or vice
versa).

But as you use it, in a logical expression, it does not seem to make sense
to me:

.HeadingFormat can only evaluate as True, False, or wdUndefined...
wdUndefined = 9999999 (... if you had multiple, mixed rows, which can't
happen in your code sample)

And wdToggle = 9999998

Each of the possible values for Selection.Rows.HeadingFormat makes the
expression True:

If Not True = 9999998 Then
== If Not False Then
== If True Then

If Not False = 9999998 Then
== If True Then

If Not wdUndefined = 9999998 Then
== If True Then

Regards,
Klaus
 
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.