gpt4 book ai didi

VBA 加载项 : how to "embed" the required reference libraries? 向其他用户发送功能加载项时获取 "Compile error in hidden module"

转载 作者:行者123 更新时间:2023-12-02 10:46:59 26 4
gpt4 key购买 nike

我编写了一个在我的本地计算机上运行良好的 powerpoint 插件。然而,当我将文件通过电子邮件发送给其他人时,突然一半的功能不再起作用,并显示主题行中列出的编译错误。

再深入一点,问题似乎是客户端计算机没有正确的引用库(例如,Excel 14.0 对象库、Outlook、Access 等)。在将加载项编写为 pptm 文件时,我正确引用了这些库,但想象一下,当我将 pptm 保存到 ppam 文件中时,引用库不知何故“丢失”了。

有没有人有任何想法?请注意,直接在客户端计算机上添加引用库似乎没有帮助。相反,我需要向客户端发送基础 pptm 文件,添加引用库,然后将该文件作为 ppam 文件直接保存在客户端计算机上,这当然是不切实际的。那么如何将引用库“嵌入”到插件中呢?

谢谢!

最佳答案

So how does one "embed" reference libraries to the add-in?



你没有。

备选 :

使用后期绑定(bind)代替早期绑定(bind)。

早期绑定(bind)的示例代码。

这里我们设置了对 MS Word xx.xx 对象库的引用。
Sub Sample()
Dim oWrd As Word.Application
Dim oDoc As Word.Document

Set oWrd = New Word.Application

Set oDoc = oWrd.Documents.Open("....")

'
'~~> Rest of the code
'
End Sub

将上述转换为后期绑定(bind)。

在这里,我们不设置引用,而是让代码绑定(bind)到目标 PC 中存在的任何版本的 MS Word。
Sub Sample()
Dim oWrd As Object
Dim oDoc As Object

Set oWrd = CreateObject("Word.Application")

Set oDoc = oWrd.Documents.Open("....")

'
'~~> Rest of the code
'
End Sub

同样,您也可以更改 MS-Excel 的代码。

For Further Reading

关于VBA 加载项 : how to "embed" the required reference libraries? 向其他用户发送功能加载项时获取 "Compile error in hidden module",我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/20463514/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com