if current selection is the whole table then

F

frogman

I have some code that selects a row in a table then hides it.
The next step is to see if the the selected object was the whole table.
if it is then hide the next blank paragraph


CODE:
Selection.HomeKey unit:=wdStory
Selection.Find.ClearFormatting
With Selection.Find
.Text = ""
.Replacement.Text = ""
.Forward = True
.Wrap = wdFindContinue
.Format = True
.Font.Italic = True
.Font.Color = wdColorBlue
.Font.Hidden = False
.MatchCase = False
.MatchWholeWord = False
.MatchWildcards = False
.MatchSoundsLike = False
.MatchAllWordForms = False
End With
Selection.Find.Execute

'Loop through and find all tables and hide the tables
While Selection.Find.Found
If Selection.Tables(1).Rows.Borders(1).Color = wdColorAutomatic
Or _
Selection.Tables(1).Rows.Borders(1).Color = wdColorBlack
Then
Selection.SelectRow
Selection.Font.Hidden = True

If Selection "if whole table is selected" = True Then
Selection.Move unit:=wdParagraph, Count:=1
Selection.Paragraphs(1).Range.Select
Selection.Font.Hidden = True
End If
End If
Selection.HomeKey unit:=wdStory
Selection.Find.Execute
Wend
 
T

Tony Jollans

Why not just check the table's Rows.Count?

If it's 1 then the one row you selected must have been the whole table.

Slightly more generally you could compare the selection's Rows.Count against
the table's.
 
G

Greg

Well if the select row was the whole table then perhaps:

If Selection.Tables(1).Rows.Count = 1 Then
 
F

frogman

I found a better solution

If Selection.Rows.Last.IsLast Then
Selection.Move unit:=wdParagraph, Count:=1
Selection.Paragraphs(1).Range.Select
Selection.Font.Hidden = False
End If
 

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