Re: finding within an only table column
- From: "Pablo Cardellino" <pablocardellino.listas@xxxxxxxxx>
- Date: Wed, 28 Jan 2009 22:02:38 -0200
Oh... that's not good...
each cell a word... the application will slow too much... I think I will
store all the texts of the first column into an external range, and perform
the searches within this range, using the paragraph number to identify de
respective table row...
Thanks, Greg
Regards,
Pablo
--
Pablo Cardellino
Florianópolis, SC
Brazil
"Greg Maxey" <gmaxey@xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx> escreveu na
mensagem news:urXoBNZgJHA.4864@xxxxxxxxxxxxxxxxxxxxxxx
AFAIK, you can't define a column as search range explicitly. What you
can do is search each cell in a specific column only:
Sub ScratchMacro()
Dim oRng As Word.Range
Dim oCell As Word.Cell
'Find and replace in column 3 only.
For Each oCell In ActiveDocument.Tables(1).Columns(3).Cells
Set oRng = oCell.Range
With oRng.Find
.Text = "Text to find"
.Replacement.Text = "Replacement Text"
.Execute Replace:=wdReplaceAll
End With
Next oCell
End Sub
--
Greg Maxey - Word MVP
My web site http://gregmaxey.mvps.org
Word MVP web site http://word.mvps.org
"Pablo Cardellino" <pablocardellino.listas@xxxxxxxxx> wrote in message
news:eES1DnYgJHA.5844@xxxxxxxxxxxxxxxxxxxxxxx
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
--
Pablo Cardellino
Florianópolis, SC
Brazil
.
- Follow-Ups:
- Re: finding within an only table column
- From: Manfred F
- Re: finding within an only table column
- References:
- finding within an only table column
- From: Pablo Cardellino
- Re: finding within an only table column
- From: Greg Maxey
- finding within an only table column
- Prev by Date: Line up frame baseline with anchoring text
- Next by Date: RE: WORD + ACCESS vb
- Previous by thread: Re: finding within an only table column
- Next by thread: Re: finding within an only table column
- Index(es):
Relevant Pages
|