确定仅在从链接打开时是否读取文档

问题描述 投票:0回答:1

如果我通过Word打开Word文档,其他人已打开,它将以只读和属性doc.readOnly = True打开。

如果我通过Chrome,Excel,Outlook等的超链接执行相同操作,则文档在Word中显示为只读,但属性为doc.readOnly = False

这使我的代码依赖于您打开文档的方式。

如何从链接打开时确定文档是否只读?它应该只在其他人打开它时触发,如果你打开它就可以了。

' *****************************************************************************
' **************** ONLY works for document that is not read only     **********
' *****************************************************************************

If doc.readOnly = True Then 'Or FileHandling.whoHasFileOpen(doc) = "" Then
    MsgBox ("You are not allowed to do changes on a read only document with our macro")
    Exit Sub
End If
vba word-vba
1个回答
0
投票

使用标题栏标题可以解决这个问题:

' *********************************************************************************************
' ************************ ONLY works for document that is not read only **********************
' *********************************************************************************************

If doc.readOnly = True Or InStr(UCase(doc.ActiveWindow.Caption), "READ-ONLY") > 0 Then
    MsgBox ("You are not allowed to do changes on a read only document with our macro")
    Exit Sub
End If
© www.soinside.com 2019 - 2024. All rights reserved.