请求的对象不可用

编程入门 行业动态 更新时间:2024-10-09 12:28:27
本文介绍了请求的对象不可用的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述

我正在尝试在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

更多推荐

请求的对象不可用

本文发布于:2023-11-28 18:07:14,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1643425.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:不可用   对象

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!