MrExcel Publishing
Your One Stop for Excel Tips & Solutions

How to set Reference in VBA


Posted by Ismo on January 25, 2000 11:19 PM

If i create new workbook (with sheets and macromodules) in VBA.
How can I Set Reference "Microsoft Visual Basic for Applications Extensibility"
to true (selected) on this new workbook in VBA macro. (Excel 97)


Posted by Celia on January 26, 2000 1:02 AM


Ismo
Go to VB Editor, open tools menu/references.., and put a check mark against "Microsoft Visual Basic for Applications Extensibility".
Celia

Posted by Ismo on January 26, 2000 2:27 AM

I mean how can I do this in VB-macro ?

Ismo

Posted by Tom Morales on January 26, 2000 11:22 AM

I believe you use the AddFromFile method. Here's a line I used in an MSWord macro to accomplish the same thing:

ActiveDocument.VBProject.References.AddFromFile "[directory]\VBEEXT1.olb"

You'll have to adjust the above for Excel object references.

Is that what you're looking for?
Tom

Posted by Ismo on January 29, 2000 11:09 AM

ActiveDocument.VBProject.References.AddFromFile "[directory]\VBEEXT1.olb" You'll have to adjust the above for Excel object references. Is that what you're looking for?

Yes that's what I want! Thank You !
Ismo

BTW: Maybe AddFromGuid "{...}" is better because Office/Excel may be
in different directory in different machines

Posted by Tom Morales on January 31, 2000 3:15 PM

Ismo - How do you determine the GUID for a library file of interest? After rattling around VBE and VBA help, the truth was, as usual, shrouded in mists. Did you get AddFromGuid working?
Tom

Posted by Ismo on February 01, 2000 11:41 PM

I run regedit and find data "VBEEXT1.olb" and take value on it.
I don't understand anything about GUID but value is same with
two tested machine.
It works on my NT4.0 and Win98 with Office97 but I think
it don't work with Office2000 because
AddFromGuid needs some version parameters?
Ismo