Excel 2007 卷影复制?

发布于 2024-09-26 05:51:09 字数 404 浏览 1 评论 0原文

我的问题是关于 Excel 加载项和 VBA 代码。

情况是这样的:

有2个Excel文件;一种是普通的 Excel 工作表,一种是带有 VBA 代码的 .xla 加载项,该代码存储在网络驱动器上。

在普通的 Excel 工作表中是对 .xla 文件的引用,以便工作表可以使用 .xla 文件中的宏。到目前为止,这工作正常,但有时似乎存在错误:看起来工作表使用了 .xla 文件的某种“影子副本”。 当我在 VBA 编辑器中更改代码或设置断点时,会出现该错误,运行宏时两者都会被忽略。感觉就像有 .xla 文件的旧副本,它是不可见的,并且以某种方式存储在普通 Excel 文件中,因此运行的代码不是我在编辑器中看到的宏。

我认为自从我安装了MS Office 2007以来就出现了这个问题。

我希望有人可以帮助我。

My question is about Excel add-ins and VBA code.

This is the situation:

There are 2 Excel files; one is just a normal Excel sheet, one is a .xla add-in with VBA code which is stored on a network drive.

In the normal Excel sheet is a reference to the .xla file so that the sheet can use the macros from the .xla file. This works fine so far, but sometimes there seems to be a bug: It looks likes the sheet uses some kind of "shadow copy" of the .xla file.
The bug occurs when I change code in the VBA editor or I set a breakpoint, both are ignored when running the macro. It feels like there is a old copy of the .xla file, which is invisible and which is somehow stored in the normal Excel file, so the code running is not the macro I see in the editor.

I think this problem has occurred since I installed MS Office 2007.

I hope someone can help me.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

梦过后 2024-10-03 05:51:09

如果 Excel 在本地存储您的加载项版本,我不会感到惊讶。当对您的 xla 进行更改时,我一定会重新添加您的加载项以确保安装最新版本。

编辑:

您可以尝试执行以下操作:

Private Sub Workbook_Open()

    Application.DisplayAlerts = False

    AddIns("Your Library Name").Installed = False 'To remove current link
    AddIns.Add Filename = "\\Your Server Path\Excel_Library3.xla"
    AddIns("Your Library Name").Installed = True

    Application.DisplayAlerts = True

End Sub

这将确保在打开 Excel 工作表时从您的网络位置加载最新的插件。

I wouldn't be surprised if Excel is storing a version of your add-in locally. When making a change to your xla, I would be sure to re-add your add-in to ensure the latest version is installed.

EDIT:

You could try doing something like this:

Private Sub Workbook_Open()

    Application.DisplayAlerts = False

    AddIns("Your Library Name").Installed = False 'To remove current link
    AddIns.Add Filename = "\\Your Server Path\Excel_Library3.xla"
    AddIns("Your Library Name").Installed = True

    Application.DisplayAlerts = True

End Sub

That would make sure the latest addin is loaded from your network location when they open the excel sheet.

明媚殇 2024-10-03 05:51:09

我没有引用文件,而是通过代码加载插件。我的用途是将我的插件存储在我的 Dropbox 文件夹中,但网络也可以同样工作。

Sub LoadAddins()

Dim wbOpen As Workbook
Dim wbNew As Workbook
Dim strAddinsPath As String
Dim strExtension As String

On Error Resume Next

strAddinsPath = "\\Server\Excel\AddIns\" 'Your server path here

ChDir strAddinsPath

strExtension = Dir("*.xlam")

        Do While strExtension <> ""
            Set wbOpen = Workbooks.Open(strAddinsPath & strExtension)
            strExtension = Dir
        Loop

On Error GoTo 0

End Sub

您需要将其添加为受信任位置,但让我将我正在处理的任何插件放入该文件夹中并让它们自动加载。

遍历我修改过的文件夹中的文件的代码:
http://www.ozgrid.com/VBA/2007-filesearch-alternative.htm

Rather than referencing the file I load the addin's via code. My use is to store my addins in my Dropbox folder but a network would work the same.

Sub LoadAddins()

Dim wbOpen As Workbook
Dim wbNew As Workbook
Dim strAddinsPath As String
Dim strExtension As String

On Error Resume Next

strAddinsPath = "\\Server\Excel\AddIns\" 'Your server path here

ChDir strAddinsPath

strExtension = Dir("*.xlam")

        Do While strExtension <> ""
            Set wbOpen = Workbooks.Open(strAddinsPath & strExtension)
            strExtension = Dir
        Loop

On Error GoTo 0

End Sub

You need to add it as a trusted location but lets me put any addin's I'm working on in the folder and having them auto load.

The code to iterate through files in a folder I modified from:
http://www.ozgrid.com/VBA/2007-filesearch-alternative.htm

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文