P
Pablo Cardellino
Hi,
I'm trying to perform a search within a certain column of a table.
Find.Execute must not match any word within the other table columns. But
this is right what happens. The Find find terms within the first column, but
find terms within de second column too.
First I'll paste the code (explained) that defines the range, which seems to
be the origin of the problem:
Set termosdic = dicDoc.Tables(1).Cell(2, 1).Range
'I begin from the second row to jump
' the header cell (which I can delete,
' if necessary)
termosdic.Select
Selection.MoveDown unit:=wdLine, Count:=dicDoc.Tables(1).Rows.Count - 2,
_
Extend:=wdExtend
' I didn't achieve to do this withous
' the Selection object
Selection.Font.Color = wdColorRed
' this colors the first column cells,
' except for the Cell(1,1)
Set termosdic = Selection.Range
termosdic.Font.Color = wdColorBlue
' this colors almost all the table,
' from the Cell(2,1) up to the last
' cell of the first column, *including*
' the cells of the other columns,
' except the ones of the last row (just
' as if I'd select using the mouse)
termosdic.Select
' just for testing purpouses: this
' selects the same thas was previously
' selected, despite the previous
' coloring action
And this is the search, which should match just terms from the first column:
With loctermosdic.Find
.Text = LCase(termo.Text)
.MatchWildcards = False
.MatchWholeWord = True
.Wrap = wdFindStop
termoachado = False
Do: While .Execute
If .Found Then
Set ch = loctermosdic.Duplicate
ch.SetRange Start:=ch.Start - 1, End:=ch.Start
If ch.Text <> "-" Then
ch.SetRange Start:=loctermosdic.End,
End:=loctermosdic.End + 1
If ch.Text <> "-" Then
termoachado = True
loctermosdic.Select
Exit Do
End If
End If
End If
Wend: Exit Do: Loop
End With
Any help will be most appreciated
Thanks in advance,
Pablo
I'm trying to perform a search within a certain column of a table.
Find.Execute must not match any word within the other table columns. But
this is right what happens. The Find find terms within the first column, but
find terms within de second column too.
First I'll paste the code (explained) that defines the range, which seems to
be the origin of the problem:
Set termosdic = dicDoc.Tables(1).Cell(2, 1).Range
'I begin from the second row to jump
' the header cell (which I can delete,
' if necessary)
termosdic.Select
Selection.MoveDown unit:=wdLine, Count:=dicDoc.Tables(1).Rows.Count - 2,
_
Extend:=wdExtend
' I didn't achieve to do this withous
' the Selection object
Selection.Font.Color = wdColorRed
' this colors the first column cells,
' except for the Cell(1,1)
Set termosdic = Selection.Range
termosdic.Font.Color = wdColorBlue
' this colors almost all the table,
' from the Cell(2,1) up to the last
' cell of the first column, *including*
' the cells of the other columns,
' except the ones of the last row (just
' as if I'd select using the mouse)
termosdic.Select
' just for testing purpouses: this
' selects the same thas was previously
' selected, despite the previous
' coloring action
And this is the search, which should match just terms from the first column:
With loctermosdic.Find
.Text = LCase(termo.Text)
.MatchWildcards = False
.MatchWholeWord = True
.Wrap = wdFindStop
termoachado = False
Do: While .Execute
If .Found Then
Set ch = loctermosdic.Duplicate
ch.SetRange Start:=ch.Start - 1, End:=ch.Start
If ch.Text <> "-" Then
ch.SetRange Start:=loctermosdic.End,
End:=loctermosdic.End + 1
If ch.Text <> "-" Then
termoachado = True
loctermosdic.Select
Exit Do
End If
End If
End If
Wend: Exit Do: Loop
End With
Any help will be most appreciated
Thanks in advance,
Pablo