Computer Forum Forum Index
Register  FAQ Profile Log in to check your private messages Log in Register 

VBA, Heading Rows Repeat & Multiple Heading Rows

 
Post new topic   Reply to topic    Computer Forum Forum Index -> word vba customization
View previous topic :: View next topic  
Author Message
Thomas
Guest





PostPosted: Mon Jun 18, 2007 10:44 am    Post subject: VBA, Heading Rows Repeat & Multiple Heading Rows Reply with quote

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 ?
Back to top
Google
Sponsor





PostPosted: Mon Jun 18, 2007 10:44 am    Post subject: Advertisement

Back to top
Helmut Weber
Guest





PostPosted: Sat Jun 30, 2007 7:03 am    Post subject: Re: VBA, Heading Rows Repeat & Multiple Heading Rows Reply with quote

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

--
Greetings from Bavaria, Germany

Helmut Weber, MVP WordVBA

Win XP, Office 2003
"red.sys" & Chr$(64) & "t-online.de"
Back to top
Klaus Linke
Guest





PostPosted: Wed Jul 04, 2007 7:04 pm    Post subject: Re: VBA, Heading Rows Repeat & Multiple Heading Rows Reply with quote

Quote:
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 ?

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
Back to top
Display posts from previous:   
Post new topic   Reply to topic    Computer Forum Forum Index -> word vba customization All times are GMT
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
Computer Forum