Solved

DBEngine object not found in Excel

Posted on 1998-11-04
12
714 Views
Last Modified: 2013-12-25
Hi,

I'm writing a little VB module that is to export data from
Excel 7.0 to an Access 7.0 Database file. I try to create a
Database Object using DBEngine.OpenConnection,
however I always get run-time error 424 - "Object
Required". Any ideas why the DBEngine object cannot
be found?

Thanx
0
Comment
Question by:bogie2
  • 3
  • 3
  • 2
  • +3
12 Comments
 

Author Comment

by:bogie2
ID: 1497434
Edited text of question
0
 
LVL 2

Expert Comment

by:Poddy
ID: 1497435
you need to add the DAO to your references
0
 

Author Comment

by:bogie2
ID: 1497436
I DO have a reference to the DAO library! And it still does not find the
object DBEngine. Very strange. Could it be registry-entry missing?

0
 
LVL 1

Expert Comment

by:csalves
ID: 1497437
Hello,

You have to check if your Excel apps is correctly registered.

If it is you have to create an variable of object type and start your object as an excel apps. What i wont to mean is:
Use the CreateObject Function or GetObject if you're already running your excel apps.

regards,

0
 
LVL 1

Expert Comment

by:csalves
ID: 1497438
I'm sorry bogie2...
0
 
LVL 13

Expert Comment

by:Mirkwood
ID: 1497439
Try this and see if it works ok
    Dim dbe As New DBEngine
    dbe.OpenConnection "apekool.mdb"

0
Do You Know the 4 Main Threat Actor Types?

Do you know the main threat actor types? Most attackers fall into one of four categories, each with their own favored tactics, techniques, and procedures.

 
LVL 5

Expert Comment

by:vboukhar
ID: 1497440
Maybe must be something like that:
    Dim wrkJet As Workspace
    Dim dbsMy As Database
    Set wrkJet = DBEngine.CreateWorkspace("special", "admin", "")
    Set dbsMy = wrkJet.OpenDatabase("d:\dict.mdb")
in ObjectBrowser I not found OpenConnection for DBEngine at all.
0
 
LVL 3

Expert Comment

by:fguerreiro_inix
ID: 1497441
Hello Bogie2

At first, if you want to create an Access 7.0 Database, you must use DBEngine.CreateDatabase to create an MDB file. If you use OpenConnection it only is going to work with ODBC Databases(Opens a Connection object on an ODBC data source - ODBCDirect workspaces only).

Look at this:

This example uses CreateDatabase to create a new, encrypted Database object.

Sub CreateDatabaseX()

   Dim wrkDefault As Workspace
   Dim dbsNew As DATABASE
   Dim prpLoop As Property

   ' Get default Workspace.
   Set wrkDefault = DBEngine.Workspaces(0)
   
' Make sure there isn't already a file with the name of
' the new database.

  If Dir("NewDB.mdb") <> "" Then Kill "NewDB.mdb"
     ' Create a new database
     Set dbsNew = wrkDefault.CreateDatabase("NewDB.mdb", _
            dbLangGeneral, dbEncrypt)
  endif
End Sub

You don't need to instatiate DBEngine.
DBEngine has a default workspace alredy created DBEngine.Workspaces(0).

Hope this helps
Regards

0
 

Author Comment

by:bogie2
ID: 1497442
Thanks for all your comments. However, I still face the same old problem.
Any reference to the DBEngine object (which should exist by default) is
flagged "Error 424 - Object required". The scripts used to work fine before,
by they stopped working when I reinstalled Windows. What could it be?
I also tried reinstalling Excel, but it does not help, unfortunately.
Any ideas?
0
 
LVL 5

Expert Comment

by:vboukhar
ID: 1497443
What about my comment?
0
 
LVL 3

Expert Comment

by:fguerreiro_inix
ID: 1497444
What's DAO version are you using?
0
 
LVL 3

Accepted Solution

by:
fguerreiro_inix earned 600 total points
ID: 1497445
Your registry must be a great confusion.

You have a problem in the registry with DAO.


Run RegClean, Unistall Access, Run RegClean, Install Access,Run RegClean again.
See it work

Regards
0

Featured Post

Do You Know the 4 Main Threat Actor Types?

Do you know the main threat actor types? Most attackers fall into one of four categories, each with their own favored tactics, techniques, and procedures.

Join & Write a Comment

If you have ever used Microsoft Word then you know that it has a good spell checker and it may have occurred to you that the ability to check spelling might be a nice piece of functionality to add to certain applications of yours. Well the code that…
You can of course define an array to hold data that is of a particular type like an array of Strings to hold customer names or an array of Doubles to hold customer sales, but what do you do if you want to coordinate that data? This article describes…
Show developers how to use a criteria form to limit the data that appears on an Access report. It is a common requirement that users can specify the criteria for a report at runtime. The easiest way to accomplish this is using a criteria form that a…
This lesson covers basic error handling code in Microsoft Excel using VBA. This is the first lesson in a 3-part series that uses code to loop through an Excel spreadsheet in VBA and then fix errors, taking advantage of error handling code. This l…

708 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

13 Experts available now in Live!

Get 1:1 Help Now