简体   繁体   English

加载 dotx 时字 VBA '文件正在使用'

[英]Word VBA 'file in use' when loading dotx

I get the message 'File In Use... locked for editing by another user...' the first time I run the following sub in a Word session.我第一次在 Word session 中运行以下子程序时,收到消息“正在使用的文件...锁定以供其他用户编辑...”。 After selecting 'Open a Read Only copy' the macro runs OK.选择“打开只读副本”后,宏运行正常。 The dotx file has the Read Only and Archive attributes set. dotx 文件具有只读和存档属性集。 Some of my users open Word sessions every few minutes (editing numerous database records one at a time in Word) and this annoys them.我的一些用户每隔几分钟打开一次 Word 会话(在 Word 中一次编辑大量数据库记录),这让他们很恼火。

Any ideas if this can be fixed?有什么想法可以解决吗?

Thanks.谢谢。

    Sub Check()
    If Left(ActiveDocument.Attached Template,3) <> "RFP" Then
        With ActiveDocument
            .UpdateStylesOnOpen = True
            .AttachedTemplate = Environ("homedrive") & "\My Documents\RFP Styles.dotx"
        End With
    End If
    End Sub

I wasn't able to re-create your error (though my dotx also has the Readonly attribute checked).我无法重新创建您的错误(尽管我的 dotx 也检查了 Readonly 属性)。 Perhaps your dotx has been inadvertently left open.也许您的 dotx 无意中被打开了。 To close any lingering copies of Windows files, go to Computer Management --> Shared Folders --> Open Files.要关闭 Windows 文件的任何残留副本,go 到计算机管理 --> 共享文件夹 --> 打开文件。 If you see your dotx file in there, there is a button to Close it.如果您在那里看到您的 dotx 文件,则有一个关闭它的按钮。

I experience the same problem since some months now, with no idea how to solve this.几个月以来我遇到了同样的问题,不知道如何解决这个问题。 To call AttachedTemplate with.dotx files on the network path seem to trigger the readonly message.在网络路径上使用 .dotx 文件调用 AttachedTemplate 似乎会触发只读消息。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM