Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 201
Default VBA code to set a reference

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

--
Trefor
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 139
Default VBA code to set a reference

Trefor:

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

you can remove this reference:

With ThisWorkbook.VBProject
Set Ref = .References("Outlook") ' Ref.Name
If Not Ref Is Nothing Then
.References.Remove Ref
End If
End With


you can list all reference

For Each Ref In ThisWorkbook.VBProject.References
i = i + 1
Cells(i, 1) = Ref.Name
Cells(i, 2) = Ref.GUID
Cells(i, 3) = Ref.Major
Cells(i, 4) = Ref.Minor
Cells(i, 5) = Ref.FullPath
Cells(i, 6) = Ref.Description
Next Ref


--

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

  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 139
Default VBA code to set a reference

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

  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 201
Default VBA code to set a reference

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

  #5   Report Post  
Posted to microsoft.public.excel.programming
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



  #6   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 201
Default VBA code to set a reference

Chijanzen,

This works, but gives me the same error as before (Can't enter break mode at
this time.)

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

The remove reference works fine thankyou.

--
Trefor


"chijanzen" wrote:

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

  #7   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 27,285
Default VBA code to set a reference

Does your xla have a unique project name or is it still the default
vbaProject? If it is, try changing it.

--
Regards,
Tom Ogilvy


"Trefor" wrote in message
...
Chijanzen,

This works, but gives me the same error as before (Can't enter break mode

at
this time.)

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

The remove reference works fine thankyou.

--
Trefor


"chijanzen" wrote:

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



Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
How to make a button VBA code reference other VBA code subroutines??? gunman[_9_] Excel Programming 4 September 27th 05 01:01 AM
Hard Code DLL Reference in VBA alex Excel Programming 0 June 10th 04 01:20 PM
Code Reference Problem Todd Huttenstine Excel Programming 0 April 28th 04 09:32 PM
remove reference via code Brian Excel Programming 1 April 22nd 04 06:10 PM
Reference a Column in Code Wally Steadman[_3_] Excel Programming 1 November 17th 03 11:26 AM


All times are GMT +1. The time now is 05:32 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Copyright ©2004-2025 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"