我正在尝试编写一个宏来添加对Skype4COM.dll库的引用,但我没有走得太远。
首先我尝试了这段代码:
ThisWorkbook.VBProject.References.AddFromFile ("C:\Program Files(x86)\Common Files\Skype\Skype4COM.dll")
但它说这种方法不值得信任。
然后我从以下代码获得此代码: How to add a reference programmatically 但我不能引用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
但是我返回nothings(我不能使用thisworkbook.vbproject.refereces), 有人可以帮帮我吗? 如果您愿意,我可以在此处粘贴所有代码。
谢谢