网络驱动器上的 Excel 文件
我工作的公司在网络驱动器上有一本非常大的主数据工作簿。还有数十个较小的“摘要”工作簿链接到同一驱动器上托管的主文件。这是我公司使用Excel作为数据库系统的尝试。这是一场难以管理的噩梦。
无论如何,问题是主文件每天会更改几次,并且每几周就会备份/重命名一次。这意味着我需要手动浏览数十个文件并更新到新文件的链接。例如,每隔几周我就必须将数十个文件和数百个选项卡中的“whatever Q3-2010.xls”更改为“whatever Q4-2011.xls”。我希望能够消除这个问题。
我有一些想法,但遇到了问题。你们中有人对如何简化这个有什么建议吗?我之前的想法/问题是:
复制主文件并将其重命名为“Whatever Current.xls”。每次文件更改时都执行此操作。这种方法的问题在于,有几个人每天都会多次更改该文件,而有人肯定会忘记。
在网络驱动器上创建主文件的快捷方式(符号链接)(即将网络驱动器上的快捷方式放在与主文件相同的目录中)。这有两个主要问题。首先,由于某种原因,我似乎无法在网络驱动器上创建快捷方式。我不知道这是一个安全问题还是无法完成。其次,当您在 Excel 中添加快捷方式的链接时,它会解析快捷方式指向的文件,而不是快捷方式本身。这并不比我们现在的更好。
- 将主文件重命名为“Whatever Current.xls”这似乎是最简单的,应该可以完美工作。不幸的是,公司政策要求文件名中包含日期或季度标识符。
现在您看到了我的问题,是否有人对如何最好地实现这一目标有任何想法? 谢谢!
编辑:拼写
编辑2:我再一次遇到了障碍。我已经使用链接创建了抽象文件,但实际上我无法将它们用作其他文件的引用。我环顾四周,看起来我必须为此使用 INDIRECT 和 CONCATENATE 函数。不幸的是,间接仅适用于打开的工作簿,并且我假设抽象文件将被关闭。我可以使用几个 Excel“扩展”来允许 INDIRECT 在封闭的工作簿上工作,但由于这必须适用于每个人,因此这不是一个选择。我现在唯一的选择是制作抽象文件,然后在引用它的每个文件中建立指向该文件的链接,然后使用 INDIRECT 作为对链接引用的引用(这变得很复杂)。有人还有其他想法吗?
EDIT3:实际上,我上面的想法行不通。评估的链接必须仍然打开(在我的例子中它是主数据表),我们不能假设它是打开的。我开始认为也许我应该使用一些 VBA 来运行查询或其他东西,但我不知道该怎么做?有什么帮助吗?
The company I work for has one very large master data workbook on a network drive. There are also dozens of smaller "summary" workbooks that link to the master file hosted on the same drive. It's my company's attempt at using Excel as a database system. It is a nightmare to manage.
Anyway, the problem is that the master file is changed several times a day and backed up/renamed every couple of weeks. This means that I need to manually go through the dozens of files and update the links to the new file. For example, I'll have to change "whatever Q3-2010.xls" to "whatever Q4-2011.xls" in dozens of files and hundreds of tabs every few weeks. I'd like to be able to do away with this.
I've had a few ideas, but have ran into problems. Do any of you have any advice on how to simplify this. My previous ideas/problems are:
Copy the master file and rename it to "Whatever Current.xls". Do this every time the file changes. The problem with this approach is that several people each change the file several times a day, and somebody is bound to forget.
Make a shortcut (symlink) to the master file on the network drive (i.e. put the shortcut on the network drive in the same directory as the master). There are two major problems with this. First, for some reason, I can't seem to create shortcuts on the network drive. I don't know if this is a security issue or just can't be done. Second, when you add a link to a shortcut in Excel, it resolves the file that the shortcut points to and not the shortcut itself. This is no better than what we have now.
- Rename the master file to "Whatever Current.xls" This seems the simplest and should work perfectly. Unfortunately company policy requires a date or quarter identifier in the file-name.
So now that you see my problem, does anybody have any ideas on how to best achieve this?
Thanks!
EDIT: Spelling
EDIT2: Once again, I ran into a snag. I've created the abstraction file with the links, but I can't actually use those as references from the other files. I've looked around and it looks like I have to to use the INDIRECT and CONCATENATE functions for this. Unfortunately, INDIRECT only works with open workbooks, and I assumed that the abstraction file would be closed. There are several Excel "extensions" that I can use to allow INDIRECT to work on a closed workbook, but since this has to work for everybody, that's not an option. My only option right now is to make the abstraction file, then make links to the file in each of the files that reference it, then use INDIRECT as a reference to the reference to the links (this is getting complicated). Does anybody have any other ideas?
EDIT3: Actually, my idea above does not work. The link evaluated must still be open (in my case it's the master data sheet) and we can't assume that it is. I'm starting to think that maybe I should use some VBA to run a query or something, but I don't know how to do that? Any help?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
我会在必要时使用 VBA 更新链接,至少直到您可以说服他们重构流程为止。在每个子工作簿中,放置一个名为 Source 的 CustomDocumentProperty 并将其值设置为源文件的完整路径。我们将使用此属性的存在来确定我们是否正在处理子工作簿。在一个新的加载项中,插入一个包含此代码的类模块
在一个标准模块(我称之为 MUtilities)中放置此代码
在另一个标准模块(MOpenClose)中放置此代码
当加载加载项时,它将创建一个新的CAppEvents 将侦听工作簿打开事件。每次打开工作簿时,它都会检查它是否相关。如果是,它将查看源文件是否仍然存在。如果没有,它将提示选择新的源文件并更新链接。
您可能需要调整逻辑,并且您肯定希望使错误处理更加健壮。
一旦开始工作,就开始编写代码,将此信息移植到 Access(或其他)数据库中。
I would use VBA to update the links when necessary, at least until you can convince them to refactor the process. In every child workbook, put a CustomDocumentProperty named Source and set it's value to the full path of the Source file. We'll use the existence of this property to determine if we're dealing with a child workbook. In a new add-in, insert a class module with this code
In a standard module (I call mine MUtilities) put this code
In another standard module (MOpenClose) put this code
When the add-in is loaded, it will create a new CAppEvents that will listen for workbook open events. Every time a workbook opens, it will check to see if it's relevant. If it is, it will see if the source file still exists. If not, it will prompt to select the new source file and update the links.
You may need to tweak the logic and you'll definitely want to make the error handling more robust.
Once you get this working, start writing the code that ports this information into an Access (or other) database.
您可以在主工作表中嵌入一个事件,该事件也会自动保存备份(您提到您担心人们会忘记),这样它就不可能不被保存并且不会以您需要的相同名称进行备份它可以减轻人们编辑文件的工作。
使用 workbook_beforesave 事件进行探索 - 每次用户尝试保存工作簿时都会启动该事件。禁用提示并以您需要的名称秘密保存备份!不要忘记在代码期间关闭事件,否则您的备份保存也会触发该事件。
You can embed the master worksheet with an event that will automatically also save the backup (which you mentioned you'd be afraid people would forget), that way it's impossible for it not to be saved and not backed up under the same name you need it to be plus remoes the work fr people editing the file.
Explore using the workbook_beforesave event - this will kick off every time the user attempts to save the workbook. Disable prompts and stealthily save the backup under the name you need it to be! Don't forget to turn off events during the code or your backup save will trigger the event as well.