vba 共享 Word 文档的 Dropbox 文件锁定
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/5886408/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
Dropbox file locking for shared Word documents
提问by user738396
I have a Word document shared with several other people in Dropbox. If a Word document is on a shared drive, users are notified if it is already opened. Since a local copy is opened in a Dropbox folder, multiple users can open and save the file ignorant of the other users state. Is there a way to add another lock to the file so that when one person has it open, others are warned if they try to open it? I am considering writing a VB macro that creates a token file. It is simplistic and there are corner cases when working offline, but we need something to avoid or at least be alerted to conflicts.
我在 Dropbox 中有一个与其他几个人共享的 Word 文档。如果 Word 文档位于共享驱动器上,则用户会收到已打开的通知。由于本地副本是在 Dropbox 文件夹中打开的,因此多个用户可以打开和保存其他用户状态的文件。有没有办法为文件添加另一个锁,以便当一个人打开它时,其他人在尝试打开它时会收到警告?我正在考虑编写一个创建令牌文件的 VB 宏。这很简单,离线工作时也有极端情况,但我们需要一些东西来避免或至少提醒冲突。
回答by Guy Starbuck
Using dropbox for this purpose is always going to have lag issues -- it simply doesn't synchronize fast enough for any "real-time" file locking solution to work.
为此目的使用 dropbox 总是会出现延迟问题——它的同步速度不够快,任何“实时”文件锁定解决方案都无法正常工作。
I suppose a VB macro could write to some central database or web service, which would then be checked on each attempt to open the file -- but as you say, you would need to code for disconnected operation, and then have some way of handling merges after connectivity is restored.
我想 VB 宏可以写入某个中央数据库或 Web 服务,然后在每次尝试打开文件时都会对其进行检查 - 但正如您所说,您需要为断开连接的操作编码,然后有某种处理方式连接恢复后合并。
I'm not sure if you have access to SharePoint, but this is really the core of what SharePoint was designed to do best, to let people safely collaborate on Microsoft Office files over a network. There is a free version of SharePoint 2010 out that you could use in an intranet setup.
我不确定您是否有权访问 SharePoint,但这确实是 SharePoint 设计的最佳核心,旨在让人们通过网络安全地协作处理 Microsoft Office 文件。您可以在 Intranet 设置中使用 SharePoint 2010 的免费版本。
回答by John Heiser
Our team used Notifybox for several months to check-out and check-in shared Excel and Word files in Dropbox. Some of the issues with Notifybox are that it sometimes misses file opens and closes, seems to block reboots on Windows XP, sometimes falsely concludes that there is no active internet connection on that PC even though Dropbox is having no problem synchronizing files, and doesn't run on Macs.
我们的团队使用 Notifybox 几个月来在 Dropbox 中签出和签入共享的 Excel 和 Word 文件。Notifybox 的一些问题是它有时会错过文件的打开和关闭,似乎会阻止在 Windows XP 上重新启动,有时会错误地断定该 PC 上没有活动的互联网连接,即使 Dropbox 同步文件没有问题,并且没有在 Mac 上运行。
I came up with some simple Visual Basic for Applications (VBA) macros that handle file check-out and check-in. We have been using them on PCs running Office 2010 and Macs running Office 2011. They have been designed to work with Office 2003 on PCs and Office 2004 on Macs but have not yet been tested in those environments.
我想出了一些简单的 Visual Basic for Applications (VBA) 宏来处理文件签出和签入。我们一直在运行 Office 2010 的 PC 和运行 Office 2011 的 Mac 上使用它们。它们旨在与 PC 上的 Office 2003 和 Mac 上的 Office 2004 一起使用,但尚未在这些环境中进行测试。
The way the macros work is that when a file is checked-out to a user, that user's name is stored as "Manager" name in the file's built-in properties and the revised file is immediately saved and synchronized through Dropbox.
宏的工作方式是,当文件签出给用户时,该用户的名称在文件的内置属性中存储为“管理员”名称,修改后的文件会立即保存并通过 Dropbox 同步。
If another user attempts to open a file that has been checked out to someone else, they will get a message that the file is currently being edited and the name of the other user is displayed.
如果其他用户尝试打开已签出给其他人的文件,他们将收到一条消息,指出当前正在编辑该文件并显示其他用户的姓名。
When the first user completes editing the file and closes it, the Manager's name in the file's built-in properties is set empty and the file is immediately saved and synchronized through Dropbox thereby checking in the file so someone else can check it out.
当第一个用户完成文件的编辑并关闭它时,文件内置属性中的管理器名称被设置为空,文件会立即保存并通过 Dropbox 同步,从而签入文件,以便其他人可以签出。
We add the macros to each shared file. You can read the documentation and download the macros at http://www.ocn.me/comacs.htm.
我们将宏添加到每个共享文件中。您可以在http://www.ocn.me/comacs.htm阅读文档并下载宏。
In the present version, if a user checks-out a file and then uses File Save As to save that file under another name, the file under the new name is checked-out to that user but the original file is not checked-in. The user is asked to reopen the original file and then close it. That will check-in the original file. Likewise, if when closing a file the user decides to discard changes, the file remains checked-out to the user. If someone leaves a file checked-out then goes on vacation, anyone can open the file and delete the Manager name in the file's built-in properties. That will force a check-in of the file.
在当前版本中,如果用户签出一个文件,然后使用文件另存为以另一个名称保存该文件,则新名称下的文件将签出给该用户,但原始文件不会签入。要求用户重新打开原始文件,然后关闭它。这将签入原始文件。同样,如果用户在关闭文件时决定放弃更改,则该文件仍对用户保持签出状态。如果有人将文件签出然后休假,则任何人都可以打开该文件并删除该文件的内置属性中的 Manager 名称。这将强制签入文件。
The macros are working great for our team. I think they could be fairly easily modified to work with other synchronization products such as Google Drive, SugarSync, or Box.com
宏对我们的团队来说非常有用。我认为它们可以很容易地修改以与其他同步产品一起使用,例如 Google Drive、SugarSync 或 Box.com