vba - How to add Microsoft ActiveX Data Objects 6.1 Library and Microsoft VBScript Regular Expressions 5.5 using macro code -
i added references .bas module through "tools...->references...". , want add references automatically, using macro code. need add 2 references: microsoft activex data objects 6.1 library
, microsoft vbscript regular expressions 5.5
. , found piece of code seems want:
sub listreferences() on error goto cannotaddreferences application.vbe.activevbproject.references.addfromfile "path_to_file" exit sub cannotaddreferences: msgbox "can not add reference" end sub
but don't know how paths of files (path_to_file
). maybe can me? in advance.
you can find file path on references vbaproject dialog (tools >> references). location property.
edit: pointed out in comments, cannot read full name. sub outputs current references.
sub readexistingrefences() ' displays current refernce names , full paths. dim ref object each ref in application.vbe.activevbproject.references msgbox "name: " & ref.name & vbcrlf & ref.fullpath next end sub
warning
you should read @macroman's comment on op. although can update references programmatically, shouldn't.
Comments
Post a Comment