5

Consider the following table in Word 2013

A BBB
A CCC
D E F

A, B and C are merged cells.

A and B are empty. C has text A inside.

Now the following code

Set rng = ActiveDocument.Range(0, 0)  
With rng.Find
    .Forward = True
    .Wrap = wdFindStop
    .Execute "A"
End With

Crashes word on Execute "A".

If I change text to Execute "B" it doesn't find anything but doesn't crash word. Issue is present only in word 2013.

We tried searching manually and Selection.Find cell by cell, but both of those are rather slow.

Is there a quick way to circumvent this error?

EDIT: this is minimum fail example that I constructed. In our application we use a lot of Range.Find, sometimes with wrap and almost never starting from Document.Start

EDIT2: further investigation shows that Error isn't present if you open Document in compatibility mode (Word 97-2003 format).

4

1 回答 1

1

而且您不能只激活.Find对象Tables(index).Selection而不是范围对象吗?

如果您只是从 ActiveDocument 中激活 .Selection 对象而不是 Table 对象,那么这可能需要很长时间。但是直接从表索引中取出会显着加快速度。

ActiveDocument.Tables(1).Select
With Selection.Find
    .Forward = True
    .Wrap = wdFindStop
    .Execute FindText:="A"
End With
于 2014-04-09T19:58:36.463 回答