D
David Waddell
Hi ,
I've found what I think to be a bug in the find object's wrap behaviour
when
applied in tables;
I'm using Word 2002 SP 2 on windows 2000 (Word Help-About shows version
10.4525.4219).
I've tun this test against word 2002, no service packs, and the bug is
not evident there.
The test, code to recreate below, involves a table with 1 row, 2 columns.
The first cell contains text
in Courier New font, the second in Arial. Executing a non-wrapping find on
the range of the second cell
for Arial font returns a match, incorrectly. The start and end positions of
the range searched on can be seen
to have jumped back to the first cell.
If any of you guys can point out that I'm doing something wrong, or shed
any more light on this,
would greatly appreciate it (It's busting our units tests
Thanks,
David.
code :
using vb6,
I get the following output in my debug window :
finder.found is True
Range start,end are now 0,32
Original start,end was 33,60
Dim app As Word.Application
Dim doc As Word.Document
Dim table As Word.table
Dim range As Word.range
Dim rangeOrig As Word.range
Dim finder As Object
' open a new doc
Set app = New Word.Application
app.Visible = False
Set doc = app.Documents.Add
' add a table
Set range = doc.range(0, 0)
Set table = doc.Tables.Add(range, 1, 2)
' first cell text in Courier New
Set range = table.Cell(1, 1).range
range.Font.Name = "Courier New"
range.Text = "This text is in courier new font"
' second cell text in Arial
Set range = table.Cell(1, 2).range
range.Font.Name = "Arial"
range.Text = "This text is in arial font"
' search for courier new font in the second cell
Set range = table.Cell(1, 2).range
Set rangeOrig = range.Duplicate ' keeping a copy for diagnostics
below
Set finder = range.Find
finder.ClearFormatting
finder.Text = ""
finder.Wrap = Word.wdFindStop
finder.Forward = True
finder.Font.Name = "Courier New"
finder.Execute
' diagnostics :
Debug.Print "finder.found is " & finder.Found
If finder.Found Then
Debug.Print "Range start,end are now " & vbTab & range.start & "," &
range.End
Debug.Print "Original start,end was" & vbTab & rangeOrig.start & ","
& rangeOrig.End
End If
I've found what I think to be a bug in the find object's wrap behaviour
when
applied in tables;
I'm using Word 2002 SP 2 on windows 2000 (Word Help-About shows version
10.4525.4219).
I've tun this test against word 2002, no service packs, and the bug is
not evident there.
The test, code to recreate below, involves a table with 1 row, 2 columns.
The first cell contains text
in Courier New font, the second in Arial. Executing a non-wrapping find on
the range of the second cell
for Arial font returns a match, incorrectly. The start and end positions of
the range searched on can be seen
to have jumped back to the first cell.
If any of you guys can point out that I'm doing something wrong, or shed
any more light on this,
would greatly appreciate it (It's busting our units tests
Thanks,
David.
code :
using vb6,
I get the following output in my debug window :
finder.found is True
Range start,end are now 0,32
Original start,end was 33,60
Dim app As Word.Application
Dim doc As Word.Document
Dim table As Word.table
Dim range As Word.range
Dim rangeOrig As Word.range
Dim finder As Object
' open a new doc
Set app = New Word.Application
app.Visible = False
Set doc = app.Documents.Add
' add a table
Set range = doc.range(0, 0)
Set table = doc.Tables.Add(range, 1, 2)
' first cell text in Courier New
Set range = table.Cell(1, 1).range
range.Font.Name = "Courier New"
range.Text = "This text is in courier new font"
' second cell text in Arial
Set range = table.Cell(1, 2).range
range.Font.Name = "Arial"
range.Text = "This text is in arial font"
' search for courier new font in the second cell
Set range = table.Cell(1, 2).range
Set rangeOrig = range.Duplicate ' keeping a copy for diagnostics
below
Set finder = range.Find
finder.ClearFormatting
finder.Text = ""
finder.Wrap = Word.wdFindStop
finder.Forward = True
finder.Font.Name = "Courier New"
finder.Execute
' diagnostics :
Debug.Print "finder.found is " & finder.Found
If finder.Found Then
Debug.Print "Range start,end are now " & vbTab & range.start & "," &
range.End
Debug.Print "Original start,end was" & vbTab & rangeOrig.start & ","
& rangeOrig.End
End If