我有一个宏,它以某种方式格式化文档,然后使用 ActiveDocument.Save
保存它。 .
但是,有时文档尚未保存,在某些情况下我不想保存它。不幸的是,在显示“另存为”对话框时单击“取消”会导致运行时错误 (4198) -
Command failed
有谁知道我如何防止这种情况发生?谢谢。
最佳答案
请通过添加一些错误处理说明来尝试以下操作:
On Error Resume Next 'to omit error when cancel is pressed
ActiveDocument.Save
If Err.Number <> 0 Then 'optional, to confirmed that is not saved
MsgBox "Not saved"
End If
On Error GoTo 0 'to return standard error operation
关于vba - 取消通过 VBA 显示的 'Save As' 对话框时出现运行时错误,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/15407281/