How can I remove a VBE reference via code?
I'm trying to use this code, but it's spawning error 438, saying the object or method is not supported:
ThisWorkbook.VBProject.References.Remove (ThisWorkbook.VBProject.References(strFilename))
The whole description:
I'm creating a script to update an add-in currently in use AND referenced by open workbooks via VBE. So I need to:
a) disable add-in
b) delete VBE ref
c) update add-in
d) reassert VBE ref
e) reenable add-in
I've got parts a), c), d) and e) working okay, but b) seems to be throwing the error (as above).
This is the entire code snippet, in case they have some interdepencies:
I'm trying to use this code, but it's spawning error 438, saying the object or method is not supported:
ThisWorkbook.VBProject.References.Remove (ThisWorkbook.VBProject.References(strFilename))
The whole description:
I'm creating a script to update an add-in currently in use AND referenced by open workbooks via VBE. So I need to:
a) disable add-in
b) delete VBE ref
c) update add-in
d) reassert VBE ref
e) reenable add-in
I've got parts a), c), d) and e) working okay, but b) seems to be throwing the error (as above).
This is the entire code snippet, in case they have some interdepencies:
Code:
strFilename = "ValidFileName.xla"
strFilePath = "C:\ValidFilePath\" & strFilename
AddIns(strFilename).Installed = False
ThisWorkbook.VBProject.References.Remove (ThisWorkbook.VBProject.References(strFilename))
AddIns.Add filename:=strFilepath
ThisWorkbook.VBProject.References.AddFromFile (strFilename)
AddIns(strFilename).Installed = True