By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
425,534 Members | 1,830 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 425,534 IT Pros & Developers. It's quick & easy.

Adding Excel Object Library Reference Programmatically

P: n/a
Hello,

I'd like to programmatically reference the Excel Object Library from an
Access form using VB. I am using this code:

Application.VBE.vbprojects("VBAProject").Reference s.AddFromFile "(file
location)"

....but get a 'subscript out of range' message. Can anyone help?

Thanks

Nov 13 '05 #1
Share this Question
Share on Google+
3 Replies


P: n/a
Look into Late Binding and you won't need to set a reference to the Excel
Library.

--
PC Datasheet
Your Resource For Help With Access, Excel And Word Applications
re******@pcdatasheet.com
www.pcdatasheet.com
"Nick Douglas" <ni*********@gmail.com> wrote in message
news:11**********************@g49g2000cwa.googlegr oups.com...
Hello,

I'd like to programmatically reference the Excel Object Library from an
Access form using VB. I am using this code:

Application.VBE.vbprojects("VBAProject").Reference s.AddFromFile "(file
location)"

...but get a 'subscript out of range' message. Can anyone help?

Thanks

Nov 13 '05 #2

P: n/a
Nick:

One thing to look at is the "VBAProject" portion of your line of code. If
this does not reference a VBA project, you will get a subscript out of range
error. The "VBAProject" portion should refer to the name of the database
name you are trying to add the reference to.

--
David Lloyd
MCSD .NET
http://LemingtonConsulting.com

This response is supplied "as is" without any representations or warranties.
"Nick Douglas" <ni*********@gmail.com> wrote in message
news:11**********************@g49g2000cwa.googlegr oups.com...
Hello,

I'd like to programmatically reference the Excel Object Library from an
Access form using VB. I am using this code:

Application.VBE.vbprojects("VBAProject").Reference s.AddFromFile "(file
location)"

....but get a 'subscript out of range' message. Can anyone help?

Thanks
Nov 13 '05 #3

P: n/a
Thanks David and PC Datasheet...I switched to late binding and all is
well!

Nov 13 '05 #4

This discussion thread is closed

Replies have been disabled for this discussion.