vba - Assign Bang argument programmatically? -


i'm not successful in using bang (!) operator without it's argument being hardcoded, i.e., me.vbproject.references!excel. in example, excel reference hardcoded. out of frustration i've tried permutations can think of in attempt utilize it:

[me.vbproject.references!(str)] [me.vbproject.references! & (str)] ["me.vbproject.references!" & str] ["me.vbproject.references!" & (str)] 

and many more parens added ensure proper pre-evaluation including longhand application.evaluate method. nada!

no, can't that.

the bang operator shortcut calling default member of object, , passing text after bang string first parameter of default member:

the bang notation:

me.vbproject.references!excel 

is equivalent to:

me.vbproject.references.item("excel") 

and, because default member, can omit item function call:

me.vbproject.references("excel") 

so, use (really badly named) variable str:

str = "excel" debug.print me.vbproject.references.item(str).name 

Comments