View Single Post
  #5   Report Post  
Posted to microsoft.public.excel.programming
chijanzen chijanzen is offline
external usenet poster
 
Posts: 139
Default VBA code to set a reference

Trefor:

' adding of a DataCollectMaster Addin refernce

ThisWorkbook.VBProject.References.AddFromFile "C:\DataCollectMaster.xla"



' Remove References
With ThisWorkbook.VBProject
For i = 1 To .References.Count
If .References(i).Name = "DataCollectMaster" Then
.References.Remove .References(i)
End If
Next i
End With

--
http://www.vba.com.tw/plog/


"Trefor" wrote:

Chijanzen,

Thankyou for your reply.

The reference is for my add-in so:

With ThisWorkbook.VBProject
Set Ref = .References("DataCollectMaster") ' Ref.Name
If Not Ref Is Nothing Then
.References.Remove Ref <-- Can't enter break mode at this time.
End If
End With

I get the above error, otherwise the reference did get removed.

can you show me how to code adding this add-in by its name?

--
Trefor


"chijanzen" wrote:

Trefor:

If you want to adding of a refernce "Microsoft Office Outlook 11.0 Object
Library"

With ThisWorkbook.VBProject
On Error Resume Next
Set Ref = .References("Outlook")
If Err = 0 Then
'Remove of a Outlook refernce
.References.Remove Ref
Else
'adding of a Outlook refernce
ThisWorkbook.VBProject.References.AddFromGuid _
"{00062FFF-0000-0000-C000-000000000046}", 1, 0
End If
End With

--

http://www.vba.com.tw/plog/


"Trefor" wrote:

Is it possible to code the adding of a refernce (VBE - Tools Refernce)? Is
it also possible to remove this reference?

--
Trefor