Solved

DBEngine object not found in Excel

Posted on 1998-11-04
12
722 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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
Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
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
 
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

Free Tool: Path Explorer

An intuitive utility to help find the CSS path to UI elements on a webpage. These paths are used frequently in a variety of front-end development and QA automation tasks.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Introduction While answering a recent question about filtering a custom class collection, I realized that this could be accomplished with very little code by using the ScriptControl (SC) library.  This article will introduce you to the SC library a…
I was working on a PowerPoint add-in the other day and a client asked me "can you implement a feature which processes a chart when it's pasted into a slide from another deck?". It got me wondering how to hook into built-in ribbon events in Office.
Get people started with the utilization of class modules. Class modules can be a powerful tool in Microsoft Access. They allow you to create self-contained objects that encapsulate functionality. They can easily hide the complexity of a process from…
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…

749 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