473,395 Members | 1,539 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,395 software developers and data experts.

Adding Excel Object Library Reference Programmatically

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
3 7987
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
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
Thanks David and PC Datasheet...I switched to late binding and all is
well!

Nov 13 '05 #4

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

13
by: Allison Bailey | last post by:
Hi Folks, I'm a brand new Python programmer, so please point me in the right direction if this is not the best forum for this question.... I would like to open an existing MS Excel spreadsheet...
6
by: Matthew Wieder | last post by:
I have the following requirements: Build a stand-alone C# application that asks the user to click in a cell in an Excel spreadsheet, and then displays the address of that cell in the C#...
1
by: SD WinGirl | last post by:
Our project is set up so that .cs source files are automatically generated. I would like to automate the adding of the .cs source files to the project (.csproj) file automatically. Are there...
17
by: Mansi | last post by:
I need to do some research on how to use excel automation from c#. Does anyone know of any good books related to this subject? Thanks. Mansi
6
by: frankplank | last post by:
Hi *, I'm wondering if it is possible to create a C# object, and reference it *explicitly* in an excel document. I imagine this will be more possible if I programmatically populate the excel...
3
by: Jim Heavey | last post by:
Trying to figure out the technique which should be used to add rows to a datagrid. I am thinking that I would want an "Add" button on the footer, but I am not quite sure how to do that. Is that...
14
by: pmud | last post by:
Hi, I need to use an Excel Sheet in ASP.NET application so that the users can enter (copy, paste ) large number of rows in this Excel Sheet. Also, Whatever the USER ENETRS needs to go to the...
5
by: Michael Russell | last post by:
Hi all, Using C#, I've created a simple wrapper class for using Excel. I have Office Pro 2003 installed on my devel machine. The wrapper class works great, reading and writing to/from Excel. ...
7
by: Eran.Yasso | last post by:
Hi, I have project that automate excel(using Excel COM) which works fine in my home. I took the project from my home to work and tried to build the project but it won't built. I get error "The...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.