Results 1 to 3 of 3
  1. #1
    Star Lounger
    Join Date
    Jan 2001
    Posts
    65
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Confining Search to First Column in Table (Word 2000 Sp1 under Win XP Pro

    Running a macro, I search for text ina document which is comprised of a table. Is there a way for me to restrict my search to only the first column of this table? Here is the code. Your help is always greatly appreciated.

    Dim FindText As String
    FindText = Menu.ListBox1.Text

    Selection.Find.ClearFormatting
    With Selection.Find
    .Text = FindText
    .Forward = True
    .Wrap = wdFindContinue
    .Format = False
    .MatchWholeWord = False
    End With
    Selection.Find.Execute

    Gary Hunt

  2. #2
    5 Star Lounger
    Join Date
    May 2001
    Location
    Stuttgart, Baden-W, Germany
    Posts
    931
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Confining Search to First Column in Table (Word 2000 Sp1 under Win XP

    Hi Gary,

    You would have to select the first column, and only search the selection.

    To select the first column, assuming the selection already is somewhere in the table:
    <pre> Selection.Tables(1).Columns(1).Select</pre>


    To restrict the search to the selection, change ".Wrap = wdFindContinue" to ".Wrap = wdFindStop".

    If you hear or heard that you should use Ranges instead of the Selection: This is an example where using the Selection is actually much faster (and easier). See Dave Rado's research if you are interested in details.

    <img src=/S/cheers.gif border=0 alt=cheers width=30 height=16> Klaus

  3. #3
    Star Lounger
    Join Date
    Jan 2001
    Posts
    65
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Confining Search to First Column in Table (Word 2000 Sp1 under Win XP

    Klaus,

    Thank you very much. This does indeed work well. And, I do remember reading in the past some of Dave's content on this but I did not think to look for that. Need to review it.

    Thanks again.

    Gary Hunt

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •