ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Reference Library (https://www.excelbanter.com/excel-programming/297358-reference-library.html)

Kevin Wickersheim

Reference Library
 
Is there any way to change this with code? I need to have
the "Microsoft Visual Basic For Applications
Extensibility" library checked.

Kevin


Chip Pearson

Reference Library
 
Kevin,

Try something like


ThisWorkbook.VBProject.References.AddFromGuid _
GUID:="{0002E157-0000-0000-C000-000000000046}", _
major:=5, minor:=3



--
Cordially,
Chip Pearson
Microsoft MVP - Excel
Pearson Software Consulting, LLC
www.cpearson.com


"Kevin Wickersheim" wrote
in message ...
Is there any way to change this with code? I need to have
the "Microsoft Visual Basic For Applications
Extensibility" library checked.

Kevin




Ron de Bruin

Reference Library
 
Use Late binding Kevin
You don't need a reference in the VBE

For example this macro from Chip's site
http://www.cpearson.com/excel/vbe.htm

Sub DeleteAllVBA()
Dim VBComp As VBIDE.VBComponent
Dim VBComps As VBIDE.VBComponents

Set VBComps = ActiveWorkbook.VBProject.VBComponents

For Each VBComp In VBComps
Select Case VBComp.Type
Case vbext_ct_StdModule, vbext_ct_MSForm, _
vbext_ct_ClassModule
VBComps.Remove VBComp
Case Else
With VBComp.CodeModule
.DeleteLines 1, .CountOfLines
End With
End Select
Next VBComp
End Sub

You can change to this

Public Sub DeleteAllVBA()
Dim VBComp As Object
Dim VBComps As Object
Set VBComps = ActiveWorkbook.VBProject.VBComponents
For Each VBComp In VBComps
Select Case VBComp.Type
Case 1, 3, _
2
VBComps.Remove VBComp
Case Else
With VBComp.CodeModule
.DeleteLines 1, .CountOfLines
End With
End Select
Next VBComp
End Sub





--
Regards Ron de Bruin
http://www.rondebruin.nl


"Kevin Wickersheim" wrote in message ...
Is there any way to change this with code? I need to have
the "Microsoft Visual Basic For Applications
Extensibility" library checked.

Kevin





All times are GMT +1. The time now is 07:27 AM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com