Share via

Excel 365 VBA

Anonymous
2019-10-11T19:41:19+00:00

When I try to open an Access database, VBA code that worked in previous versions of Excel stops with

Run-time error '-2147221164 (800040154)':

Class not registered

What references do I need?  Is this the right method?CODE:

  Dim db As Database

  Set db = OpenDatabase(sPath & "\MyDB.mdb", False, _

                                     False, "MS Access;PWD=" & sPW)

Microsoft 365 and Office | Access | For home | Windows

Locked Question. This question was migrated from the Microsoft Support Community. You can vote on whether it's helpful, but you can't add comments or replies or follow the question.

0 comments No comments

Answer accepted by question author

HansV 462.6K Reputation points
2019-10-11T20:53:23+00:00

Have you set a reference in Tools > References to the Microsoft Office 16.0 Access database engine Object Library?

Was this answer helpful?

4 people found this answer helpful.
0 comments No comments

1 additional answer

Sort by: Most helpful
  1. Anonymous
    2019-10-14T13:46:59+00:00

    That worked!

    Thank you, HansV

    Was this answer helpful?

    0 comments No comments