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 2005

Tip: Looking for answers? Try searching our database.

Find text in table and select table

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
Beginner in vba - 28 Jul 2005 10:48 GMT
I need to find a table (in a document that have alot of table) in which one
of the column has "name". If the table has the word "name" then it will
calculate the number of row and column of the table. I still cant seems to
code it. Thanks for the help.
Helmut Weber - 28 Jul 2005 13:16 GMT
Hi,

like this, unless "name" appears a million times
outside of tables. In that case it would be better,
to restrict the search to the tables only.

Sub test5867()
Dim rDcm As Range
Set rDcm = ActiveDocument.Range
ResetSearch
With rDcm.Find
  .Text = "name"
  .MatchCase = True
  .MatchWholeWord = True
  While .Execute
     If rDcm.Information(wdWithInTable) Then
        rDcm.Select
        Exit Sub
     End If
  Wend
End With
ResetSearch
End Sub

Public Sub ResetSearch()
 
With Selection.Find
  .ClearFormatting
  .Replacement.ClearFormatting
  .Text = ""
  .Replacement.Text = ""
  .Forward = True
  .Wrap = wdFindContinue
  .Format = False
  .MatchCase = False
  .MatchWholeWord = False
  .MatchWildcards = False
  .MatchSoundsLike = False
  .MatchAllWordForms = False
  .Execute
End With

End Sub

And please let us know, whether this was helpful.

Greetings from Bavaria, Germany
Helmut Weber, MVP
"red.sys" & chr(64) & "t-online.de"
Word 2002, Windows 2000
Helmut Weber - 28 Jul 2005 13:24 GMT
>       If rDcm.Information(wdWithInTable) Then
>          rDcm.Select ' for testing
         rdcm.tables(1).select   ' ---- add this line ----
>          Exit Sub

Helmut Weber
 
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.