如何停止 Excel 存储 XLA 的绝对路径?
我有一个 XLA 文件,要作为 Excel 加载项部署到组织中的许多用户。我的目的是将其部署到“Application Data\MyCompany”中用户“文档和设置”文件夹中的目录中。 (事实上,这一切都是通过一个包装器来完成的,该包装器在本地复制最新版本的 XLA 并将其安装为 Excel 加载项)。
但是,如果用户创建引用此 XLA 中定义的函数的工作表,则 Excel 会在函数调用中存储 XLA 的绝对路径。因此,如果用户将工作表发送给同事,Excel 将无法解析该函数,因为他们的 XLA 副本位于不同的绝对路径(因为他们的用户名是绝对路径的一部分)。
到目前为止,我的信念是,只要将 XLA 作为加载项安装,Excel“就可以应对”此问题,但情况似乎并非如此。
我真的需要为所有用户强制执行相同的加载项绝对路径吗?这在单个组织内是可能的,但老实说我不敢相信这是真的,因为它严重阻碍了 XLS 文件的共享。
谢谢。
I have an XLA file that is to be deployed to a number of users in the organisation as an Excel add-in. My intention is to deploy it to a directory in the user's "documents and settings" folder in "Application Data\MyCompany". (In fact this is all working through a wrapper that copies the latest version of the XLA locally and installs it as an Excel add-in).
However, if a user creates a sheet that references a function defined in this XLA then Excel appears to store the absolute path of the XLA in the function call. Thus, if the user sends the sheet to a colleague Excel fails to resolve the function as their copy of the XLA resides at a different absolute path (as their username is part of the absolute path).
My belief up until now was the Excel "just coped" with this as long as the XLA was installed as an add-in but this does not appear to be the case.
Is it really the case that I need to enforce an identical absolute path for my add-in for all users? This is possible within a single organisation but I honestly can't believe this is true as it seriously impedes sharing of XLS files.
Thanks.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(5)
没有什么好的方法可以做到这一点。我将 xla 文件放在网络共享上而不是本地,并通过 UNC 路径安装它们。这仅对我有效,因为每个人都可以访问该共享,但对您来说可能并非如此。这是其他一些替代方案
http:// www.dailydoseofexcel.com/archives/2008/06/02/fixing-links-to-udfs-in-addins/
There's no good way to do this. I put my xla files on a network share rather than locally and install them via the UNC path. That only works for me because everyone has access to the share, which may not be the case for you. Here's some other alternatives
http://www.dailydoseofexcel.com/archives/2008/06/02/fixing-links-to-udfs-in-addins/
我只是用像这样的子程序删除路径:
I simply remove the path with a sub like this one:
您可以指定基于环境变量的路径吗?例如
%APPDATA%\MyCompany
Can you specify an environment variable-based path? E.g.
%APPDATA%\MyCompany
我所做的是,如果我给用户一个 XLS ,它在其打开事件中包含一些代码 - 将 XLA 安装为其打开事件的一部分。它还会卸载旧版本(如果有)(删除和命令栏)。这个自我分发。理论上它可以清理任何路径。这假设有一些每个人都可以访问的共享驱动器,这会阻止他们将 XLA 复制到本地驱动器。或者通过电子邮件向他们发送 XLA 的快捷方式,其中 XLA 位于共享驱动器上。如果可能的话,您不希望本地驱动器上有 XLA。
如果 XLA 必须位于本地驱动器上 - 不确定这是否有效,但打开事件上的 XLS 可以检查修复任何路径并安装/安装 xla - 如果它知道它在哪里。但是,如果您通过互联网发送 XLS,XLS 的 on open 事件可以检查 XLA 是否可用,并弹出一个消息框,告诉用户要做什么 - 安装此 xla,这将是一个单独的附件。作为其开放活动的一部分,XLA 可以清理任何路径 - 只是一些想法。
另一种可能性是打开事件时的 XLA 可以修改打开事件时的 XLS,以便如果分发了该 XLS,则 XLS 将能够检查 XLA 是否可用。棘手。
What I have done is if I give a user a XLS , it has in its on open event some code which - installs the the XLA as part of its on open event. It also uninstalls old version if any (delete and command bars). This self distributes. In theory it could clean up any paths. This assumes there is some shared drive which everyone can access, this prevents them copying the XLA to local drive. Alternatively email them a shortcut to the XLA with XLA on the shared drive. If possible you don't want an XLA on a local drive.
If the XLA must be on a local drive - not sure if this would work but an XLS on open event could check an fix any paths and install /install a xla - if it knows where its is. But if you were emailing a XLS over the internet, the on open event of the XLS could check if the XLA is available and put up a message box telling the user what to do - install this xla, which would be a separate attachment. The XLA could clean up any paths as part of its on open event - just some ideas.
another possibility is the XLA on open event can modify the XLSs on open event so that if that XLS is distributed the XLS will be able to check if the XLA is available. Tricky.
这是一个糟糕的疏忽,导致加载项几乎无法管理以供共享使用。除此之外,使用 .XLAM 加载项是避免启用启用宏的电子表格的好方法(共享电子表格可以在没有宏的情况下进行分发,并且宏可以驻留在 .XLAM 中)
It's a poor oversight that makes add-ins barely manageable for shared use. Other than this, using .XLAM add-ins is a good way to avoid having to have macro-enabled spreadsheets (the shared spreadsheet can be distributed without macros and the macros can reside in an .XLAM)