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 / October 2005

Tip: Looking for answers? Try searching our database.

if current selection is the whole table then

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
frogman - 05 Oct 2005 16:41 GMT
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
Tony Jollans - 05 Oct 2005 16:57 GMT
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.

--
Enjoy,
Tony

> 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.
[quoted text clipped - 38 lines]
>         Selection.Find.Execute
>     Wend
frogman - 05 Oct 2005 19:48 GMT
Thanks i totally missed that.

It works great.
frogman - 12 Oct 2005 15:13 GMT
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
Greg - 05 Oct 2005 16:57 GMT
Well if the select row was the whole table then perhaps:

If Selection.Tables(1).Rows.Count = 1 Then
 
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.