本文介绍了请求的对象不可用的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我正在尝试在Mac Word文档上运行以下宏:
I'm trying to run the following macro on a Mac Word document:
Sub AcceptDeletion() Dim oChange As Revision For Each oChange In ActiveDocument.Revisions With oChange If .Type = wdRevisionDelete Then .Accept End If End With Next oChange End Sub它在以下问题中发布:要接受的Microsoft Word VBA脚本所有删除?
It is posted in this question: Microsoft Word VBA script to accept all deletions?
它清除了几个已删除的修订,但是在这里失败了:
It cleared several deleted revisions but then failed here:
If .Type = wdRevisionDelete Then...具有请求的对象不可用"的信息;运行时错误(5852).
...with "Requested Object is not Available" run-time error (5852).
任何想法如何解决?我尝试添加isMissing/IsError或将Nothing与Nothing作比较,但没有成功.
Any idea how to solve that? I tried adding isMissing / IsError or to compare to Nothing as a safeguard without success.
推荐答案在@GSerg回答之后,我对脚本进行了如下修改,并且可以正常工作:
Following @GSerg answer, I modified the script as follows and it works:
Sub AcceptDeletions() Dim oChange As Revision For i = ActiveDocument.Revisions.Count To 1 Step -1 If ActiveDocument.Revisions(i).Type = wdRevisionDelete Then ActiveDocument.Revisions(i).Accept End If Next i End Sub更多推荐
请求的对象不可用
发布评论