VBA_Excel中改如何定义word中的Paragraph,详见以下代码。

Dim i As Paragraph ‘由于是在Excel中对Word进行操作。此处在定义对象时,无法使用。
Application.ScreenUpdating = False
For Each i In ActiveDocument.Paragraphs

If Len(Trim(i.Range)) = 1 Then
i.Range.Delete

End If
Next

Application.ScreenUpdating = True

我也碰到了类似的问题,多次百度后终于解决了。我想问题在于这句For Each i In ActiveDocument.Paragraphs,因为你是在excel中建立的word进程,所以ActiveDocument.Paragraphs前面应该加上进程名。比如doc.ActiveDocument.Paragraphs
温馨提示:答案为网友推荐,仅供参考
相似回答