473,386 Members | 1,706 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,386 software developers and data experts.

adding library references via VBA - worked before but now it doesn't

Hello

I work on a database that needs to work on French and English version of Windows and Office - and work on computers with any combination of Windows 2000, Windows XP, Office 2000, Office XP, Office 2003.

The database was transferable between all of the above but to make it work it was necessary to remove some reference libraries - in particular, Microsoft Excel object library, ADOX and ADOR because they have different locations depending on what combination of systems resided on the computer one was using.

The removing of the reference libaries and reinstalling on startup worked very well for the past 4 years, but now Access, will not allow it. It stops the VBA when it finds reference to Excel objects in the code before it has executed the code to add the object libraries.

The code I am using to add the libraries is as follows:
Expand|Select|Wrap|Line Numbers
  1. Set fs = CreateObject("scripting.filesystemobject")
  2.  
  3. Set ref = Application.References("adodb")
  4. 'if error boolAdd is set to true
  5. If boolAdd Then
  6.     'check to see if it a French system
  7.     If fs.folderexists(strDriveLetter & cstrRoot & cstrComFilFr) Then
  8.         Set ref = Application.References.AddFromFile(strDriveLetter & cstrRoot & cstrComFilFr & cstrSysADO & cstrADO)
  9.     'otherwise set it for English system
  10.     Else
  11.         Set ref = Application.References.AddFromFile(strDriveLetter & cstrRoot & cstrComFil & cstrSysADO & cstrADO)
  12.     End If
  13.     boolAdd = False
  14. End If
  15.  
  16.  
The problem is that VBA now stops the execution of the code because it says excel.worksheets is a user defined type that is not defined.

Any suggestions?

Thanks
George
Oct 3 '06 #1
1 6508
dima69
181 Expert 100+
I had the similar problem ones, and I tried to use the similar code to reconnect to library database at startup.
So I've seen two possible scenarios:
1. Access MDB updates the reference by himself, althogh the location is not the same.
2. Access fails to update the reference and raises an error, before the execution of my code.

In both cases, the above code of updating references becomes useless, not to mention it will not work in mde.

I'd suggest to use late binding when possible, especially with Excell.
Oct 3 '06 #2

Sign in to post your reply or Sign up for a free account.

Similar topics

2
by: JD | last post by:
I'm trying to add a custom utility.mde reference to an application from code using the standard Application.References.AddFromFile code. IT has worked really well with A2K for a couple of years but...
7
by: Mathew Hill | last post by:
I am a beginner to the more technical aspects of Microsoft Access (2000) and was wondering if any one can help. I have 3 buttons on a form which add, delete and search for a record. However, when I...
9
by: Ben Dewey | last post by:
Project: ---------------------------- I am creating a HTTPS File Transfer App using ASP.NET and C#. I am utilizing ActiveDirectory and windows security to manage the permissions. Why reinvent...
18
by: Praveen Ramesh | last post by:
Hi, Is there any way to add the @Assembly reference to the aspx files programmatically from inside a custom control (when it gets dropped on to the page from the toolbox)? I have a custom...
1
by: Brian Henry | last post by:
My main project really only has one reference in it that is needed outside of the System references. It references a DLL Class Library which has references in that DLL library to other references...
3
by: _DS | last post by:
The two obvious methods for ref'ing assemblies are: Add a reference and 'Browse' for the actual DLL OR Add existing project to the solution, then add a ref to 'Project'. 1: I'd like to...
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. ...
2
by: JB | last post by:
I have existing aspx pages that I'm editing in VS 2005 that I add a server control to - like a label. I include the runat="server" and it doesn't seem to create the reference in the code behind for...
14
by: Jeroen | last post by:
Hi all, I've got a question about writing a library. Let me characterize that library by the following: * there is a class A which is available to the user * there is a class B that is used...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
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: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
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
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...

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.