1

我正在尝试编写一个宏来添加对 Skype4COM.dll 库的引用,但我还没有走远。

首先我尝试了这段代码:

ThisWorkbook.VBProject.References.AddFromFile ("C:\Program Files(x86)\Common Files\Skype\Skype4COM.dll")

但它说该方法不可靠。

然后我得到了这段代码: How to add a reference programmatically But I can't reference to VBIDE.VBE

最后我尝试使用 GUID 的东西,所以我从这个 http://www.vbaexpress.com/kb/getarticle.php?kb_id=267得到了代码

并找到我使用的 GUID 代码

Option Explicit 

Sub ListReferencePaths() 

On Error Resume Next 
Dim i As Long 
With ThisWorkbook.Sheets(1) 
    .Cells.Clear 
    .Range("A1") = "Reference name" 
    .Range("B1") = "Full path to reference" 
    .Range("C1") = "Reference GUID" 
End With 
For i = 1 To ThisWorkbook.VBProject.References.Count 
    With ThisWorkbook.VBProject.References(i) 
        ThisWorkbook.Sheets(1).Range("A65536").End(xlUp).Offset(1, 0) = .Name 
        ThisWorkbook.Sheets(1).Range("A65536").End(xlUp).Offset(0, 1) = .FullPath 
        ThisWorkbook.Sheets(1).Range("A65536").End(xlUp).Offset(0, 2) = .GUID 
    End With 
Next i 
On Error Goto 0 
End Sub 

但是我什么都没有返回(我不能使用 thisworkbook.vbproject.refereces),任何人都可以帮助我吗?如果你愿意,我可以在这里粘贴所有代码。

谢谢

4

0 回答 0