Heading One in a Table

S

Steve Wylie

The following macro finds Heading 1 styles that occur in
a table. But it doesn't work if an empty cell is in
Heading 1, but contains nothing. How can it be altered
to detect a Heading 1 in a table cell that contains no
text?

Steve Wylie

With Selection.Find
.Format = true
.ClearFormatting
.Style = "Heading 1"
.Text = ""
Do While .Execute
If Selection.Information(wdWithinTable) Then
Exit Do
End If
Loop
End With
 
S

Steve Hudson

G'day "Steve Wylie" <[email protected]>,

change
If Selection.Information(wdWithinTable) Then
Exit Do
End If

to
with Selection
If .Information(wdWithinTable) and len(.range.text) > 2 Then
Exit Do
End If
end with

Steve Wylie said:
The following macro finds Heading 1 styles that occur in
a table. But it doesn't work if an empty cell is in
Heading 1, but contains nothing. How can it be altered
to detect a Heading 1 in a table cell that contains no
text?

Steve Wylie

With Selection.Find
.Format = true
.ClearFormatting
.Style = "Heading 1"
.Text = ""
Do While .Execute
If Selection.Information(wdWithinTable) Then
Exit Do
End If
Loop
End With

Steve Hudson

Word Heretic, Sydney, Australia
Tricky stuff with Word or words for you.
wordheretic.com

If answers r 2 terse, ask again or hassle an MVP,
at least they get recognition for it then.
Lengthy replies offlist require payment.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top