以编程方式打开excel文件时未加载加载项 [英] Add-ins not loading when opening excel file programmatically

查看:215
本文介绍了以编程方式打开excel文件时未加载加载项的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我以前见过其他人描述过的一些类似问题,但没有真正的解决方案。我肯定有一个。

I've seen some similar problems described by others before but no real solution. And I'm sure there is one.

我有一个.XLA-add配置为在打开Excel时加载。当我打开文档或自己使用Excel时,它工作正常。但是,当我的BI系统以编程方式创建并打开Excel文件时,不会加载该加载项。 BI系统会在新实例中打开Excel,因此事先打开Excel(并因此打开.XLA-add)会无济于事。

I have a .XLA-add in configured to be loaded when I open up Excel. It works fine when I open documents or Excel it self. However, when my BI-system programmatically creates and opens an Excel-file the add-in does not get loaded. The BI-system opens Excel in a new instance so it does not help to have opened Excel on beforehand (and thereby the .XLA-add in)

如果i Check Options -Add Ins看起来好像加载了加载项,但没有加载!

If i Check Options-Add Ins it looks like the add-in is loaded but it is not!

我尝试过(并且确实可行)的是插入此功能到创建的excel文件中并重新加载加载项,但是我想找到一个自动化的解决方案!

What I've tried (and that does work) is to insert this function into the created excel-file and "reload" the add-ins, but I want to find an automated solution!

Function ReloadXLAddins(TheXLApp As Excel.Application) As Boolean
    Dim CurrAddin As Excel.AddIn

    For Each CurrAddin In TheXLApp.AddIns
        If CurrAddin.Installed Then
            CurrAddin.Installed = False
            CurrAddin.Installed = True
        End If
    Next CurrAddin
End Function

实例化excel时是否有任何方法可以自动加载我的加载项以编程方式?

Is there any way to load my Add ins automatically when instancing excel programmatically?

任何提示,解决方案或解决方法都受到高度赞赏!

Any tips, solutions or workarounds are highly appreciated!

最诚挚的问候。

推荐答案

在VBA中可能无法实现。我之前遇到过此问题,并使用过以下实现: Excel互操作加载XLL和DLLs

This may not be possible in VBA. I have come across this problem before, and used the implementation found here: Excel interop loading XLLs and DLLs

但是,该解决方案适用于C#。当来自Excel VBA脚本内部时,可能无法执行所需的步骤。也许有一些VBA实现可以看一下,但是想给您一些起点,因为我知道那是一个令人沮丧的地方。

However, that solution is for C#. The steps required may not be possible when coming from inside of an Excel VBA script. Perhaps there are some VBA implementations you can look at, but wanted to give you some sort of starting place because I know that is a frustrating place to be.

这篇关于以编程方式打开excel文件时未加载加载项的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆